12/10/2008 I’ve verified that this also works for Ubuntu 8.10 (Intrepid Ibex). I also made a couple of cosmetic changes in places where line breaks weren’t appearing properly. Entering the information without the right line breaks prevented the changes from working properly.
When I made the switch to Linux at work, I knew that I would have to make some adjustments to my workflow and retrain my muscle memory for certain tasks. To be honest, I really thought there would be many more than I’ve run into so far. One of those that I have run into involves the functionality of the scroll wheel button on my mouse.
On Windows (and also on Mac, I think), I use drivers that allow me to use the scroll wheel button to provide single-click access to the double-click action. I love that convenience and missed it after the switch. Moreover, the default Ubuntu action of pasting when I clicked the scroll wheel button left me with a lot of interesting and unintended results as well as an unnaturally smooth Ctrl+Z motion. The latter reason prompted me to dig around. I mean, it has to be possible, right?
It is possible, but it was more difficult to find that I would have thought. In my mind, everyone should be using this shortcut so there should be lots of information out there. Except that there’s not, so maybe I’m one of only a few who prefer this use for the scroll wheel button. Either way, I was finally able to track down a solution in the Ubuntu Forums that was easy to implement and works beautifully.
The original thread message contains a lot of useful information, but is more long-winded than I want next time I need to remember how to do this, so here’s the distilled version:
The steps below assume that you have a mouse with a scroll wheel and that the scroll wheel and its button are recognized by the operating system. A “recognized” scroll wheel will probably, well, scroll. A “recognized” scroll wheel button may perform a paste operation.
Install xautomation and xbindkeys Packages
Open a terminal window and type:
$ sudo apt-get install xautomation xbindkeys
Determine the Scroll Wheel Button Number
At your shell prompt, enter:
A small window should open. Move the mouse into that window and, ignoring all of the output that is generated during the movement itself, click the scroll wheel button. The output generated by the click is also verbose, but the important part should look something like this:
ButtonRelease event, serial 28, synthetic NO, window 0x3e00001, root 0x61, subw 0x3e00002, time 13989572, (43,42), root:(1138,881), state 0x100, button 2, same_screen YES
In the third line, the button is identified on my mouse as button 2. That number may be different for your mouse. Make a note of the button number. Seriously. Write it down. Now.
Edit the xbindkeys Config File
Technically, this is a create and edit operation, but you get the idea.
$ vi ~/.xbindkeysrc
In that file, add the following lines:
"/usr/bin/xte 'mouseup 2' 'mouseclick 1' 'mouseclick 1' &" b:2 + Release
Replace the “2” values with the button number you found above (you did make a note of it, didn’t you?) if the scroll wheel button isn’t the second button on your mouse. In the second line, you can remove the “ + Release” portion if you want the double click to be recognized on “mousedown” as opposed to “mouseup”.
To test, run xbindkeys in the foreground so that any errors will be output to the terminal display:
xbindkeys -n -v
Now ensure that the double click action is responding as expected. If it is, then kill the foreground process by typing Ctrl+C and restart xbindkeys as a background process:
Set xbindkeys to Start When X Loads
I did this using the GUI by going to System > Preferences > Sessions > Startup Programs. Add a new startup item as:
These steps worked brilliantly on Ubuntu 18.104.22.168. If you’re waiting for me to say that your mileage may vary, well, I guess I just did.
For those who want to read more, the forum message really is full of good information.