I finally came up with a solution that works very well for most of my use-cases. Using xdotools
, I created two scripts, one for scrolling in each direction. This is the script for scrolling down (to scroll up, substitute '5' for '4').
#!/bin/bash #Get active window id win=`xdotool getactivewindow` #Move the mouse to the active window xdotool mousemove --window $win 45 110 #Scroll active window several times xdotool click --clearmodifiers 5 xdotool click --clearmodifiers 5 xdotool click --clearmodifiers 5 xdotool click --clearmodifiers 5 xdotool click --clearmodifiers 5 xdotool click --clearmodifiers 5 xdotool click --clearmodifiers 5 xdotool click --clearmodifiers 5 xdotool click --clearmodifiers 5 xdotool click --clearmodifiers 5 xdotool click --clearmodifiers 5 #Send click to specific window. Finicky. #xdotool click --window $win 5
Basically, xdotools get the activewindow id and then moves the moves there before sending the mouse scroll signal several times. I could not get it to work by directly specifying which window to send the clicks to, so I solved it by moving the mouse cursor instead. Since Linux automatically scrolls the window under the mouse, this solves problem 1 listed in my question. The --clearmodifiers
parameter releases whatever modifier key used in the hotkey combination so that the only key that is sent is the one from xdotool, this solves problem number 2 for me.
The only minor annoyance left is that in some windows, there are multiple panels and with this script I can only scroll the top leftmost panel. This is not a problem when browsing but for IDEs such as spyder. So if someone has a better approach, please share!