在bash脚本中检测鼠标单击

时间:2011-12-02 19:02:53

标签: bash unix mouse

我想知道如何在后台运行bash脚本,只要用户点击鼠标就可以执行某些操作(即运行脚本或命令等)。即使终端关闭,我也希望继续运行。有任何想法吗?谢谢!

3 个答案:

答案 0 :(得分:4)

如果您使用的是X11,则可以尝试xdotool来捕捉鼠标事件

这将是:

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

xdotool manual

如果要在后台运行脚本,可以使用:

./myscript.sh &>/dev/null &

答案 1 :(得分:2)

如果你只是想在鼠标点击(或滚轮事件)的xterm中运行bash命令,你可以试试这个例子:

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

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

这适用于轮子事件(替代点击集12)

答案 2 :(得分:0)

要在终端关闭时保持脚本运行,您可以尝试 nohup