I'm wondering how to run a bash script in the background that will do something (i.e. run a script, or a command, or whatever) whenever a user clicks the mouse. I'd like this to continue running even if the terminal is closed. Any ideas? Thanks!
If you are using X11, you can try xdotool
to catch mouse events
It would be something like:
xdotool search --onlyvisible . behave %@ mouse-click getmouselocation
xdotool manual
If you want to run the script in background you can use:
./myscript.sh &>/dev/null &
if you just want to run bash command in xterm on mouse click (or wheel event) you can try this example:
$ echo -e "\e[?1000h"
$ while read -n 6; do echo hellowworld; done
this is for wheel event (for click set 12 instead)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With