I need make a small script in bash using xdotool. And I have problem with if statements. How to write correctly this instruction.
if [xdotool click 1] then ./myScript.sh fi
% If I make mouseclick I want to execute bashscript Please help.
#/bin/bash
xdotool click 1
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
./myScript.sh
fi
exit code 0 - means that you program executed successfully
UPD:
xdotool click 1 && ./myScript.sh
There is a feature in xdotool called behave to take an action based on some event like mouse-click But...
The specific mouse-click option is not working (apparently a bug),which is:
xdotool search . behave %@ mouse-click exec 'myscript.sh'
Although these commands work with mouse-move / mouse-leave option, which are:
xdotool search . behave %@ mouse-move exec 'myscript.sh'
xdotool search . behave %@ mouse-leave exec 'myscript.sh'
Another solution would be using echo -e like this:
echo -e "\e[?1000h"
while read -n 12; do myscript.sh; done