The Musing
About a year or two ago, I began using a trackball – I said I would never use a trackball, but whatever. Specifically, I began using the Logitech M570. It took a while to get used to it, but after the initial break-in period, I’m pretty good with it.
I use synergy (I donate – you should, too) to manage multiple computers from my M570 and Microsoft Natural Keyboard 4000 (I’ve been hooked on the curved keyboard for a decade and a half, now), but I never utilized the extra buttons on the M570.
To minimize jumping back and forth from the keyboard to the trackball, I went on a mission to both distract myself from work, and also conquer this most important problem.
After some quick Googling about how to map mouse buttons in Fedora 21, I came across a few sites like this one and this one. It looked like it was possible using xte from xautomation, xev from xorg-x11-utils, and xbindkeys.
I used dnf to install those packages, then I used xev to find out the IDs of my trackball buttons (mine were 8 and 9). I decided to map those buttons to the Home and End keys, but when coupled with the Ctrl key, they would act like Ctrl-Page Up and Ctrl-Page Down.
Why those keys?
I chose Home and End, because the trackball wheel conquers Page Up/Down pretty well in a browser or terminal window, but sometimes I want to go to the top/bottom of a long page quickly; Home/End send like a logical choice.
I use Ctrl-Page Up/Down to switch tabs in gnome-terminal and Firefox, so having that ability without switching my right hand to the keyboard seemed to make sense.
The Fix
First, I installed the necessary packages on Fedora with
sudo dnf -y install xbindkeys xautomation
I generated the defaults .xbindkeysrc file with
xbindkeys --defaults > $HOME/.xbindkeysrc
then commented out all of those lines and added this:
# Page Down "xte 'keydown Home' 'keyup Home'" b:9 # Page Up "xte 'keydown End' 'keyup End'" b:8 # Toggle tabs left "xte 'keydown Page_Up' 'keyup Page_Up'" control + b:9 # Toggle tabs right "xte 'keydown Page_Down' 'keyup Page_Down'" control + b:8
I started xbindkeys and it worked! Not the first time of course, but when does that ever happen? I had to tweak a bit to get the above additions to .xbindkeysrc.
Then I wanted to make sure that xbindkeys started on boot – that was harder than I imagined. I used the gnome-tweak-tool to add the application to startup, after adding a xbindkeys.desktop file to ~/.config/autostart/. It looks like:
[Desktop Entry] Name=xbindkeys GenericName=xbindkeys Comment=Start these up at login Exec=/usr/bin/xbindkeys Terminal=False Type=Application X-GNOME-Autostart-enabled=true
And that was it! Not a big task, but – if I can train myself to use them – could prove to be a time saver and increase my productivity. Of course, not spending an hour or so implementing this fix might’ve improved my productivity, too!