I like to trigger an AutoKey script by pressing middle mouse (restricted to a certain application via window filter). Unfortunately AutoKey only lets me set keyboard short-cuts while mouse buttons are completely ignored. It seems AutoKey does not at all allow mouse buttons as triggers. (See selection screen below.)
Is there any workaround that lets me run an AutoKey script via pressing a mouse button?
Take a look at xbindkeys. I use it to make single modifier keys to hotkeys (such as RCtrl), but I read it is also capable of using mouse buttons as trigger. https://www.linux.com/news/start-programs-pro-xbindkeys
Then you can assign a command like "bash -c 'xdotool key Ctrl+Shift+Super+Alt+1'" to the mouse button, and make a Hotkey-Script in Autokey waiting for this combination.
The format is
"some_command --with-args"
Modifier + key
Example ~/.xbindkeysrc
mapping middle-mouse to ctrl+left-mouse:
"xte 'keydown Control_L' 'usleep 200000' 'mouseclick 1' 'usleep 200000' 'keyup Control_L'"
b:2
Example mapping alt-left-mouse to a log statement:
"date >> ~/clicklog.txt"
Control + b:1
You can force reload with pkill -ife xbindkeys; xbindkeys
.
To get these packages:
sudo apt-get install xbindkeys
sudo apt-get install xdotool # if you need xdotool
sudo apt-get install xautomation # if you need xte