Detect mouse click in bash script

I am wondering how to run a bash script in the background, which will do something (for example, run a script or command or something else) whenever the user clicks on the mouse. I would like this to continue even if the terminal is closed. Any ideas? Thank!

+5
source share
3 answers

If you use X11, you can try xdotoolto catch mouse events

It will be something like:

xdotool search --onlyvisible . behave %@ mouse-click getmouselocation

xdotool manual

If you want to run the script in the background, you can use:

./myscript.sh &>/dev/null &
+4
source

bash xterm ( ), :

$ echo -e "\e[?1000h"

$ while read -n 6; do echo hellowworld; done

( 12)

+2

To keep the script running even when closing the terminal, you can try nohup .

0
source

All Articles