Logitech MX Revolution on Ubuntu Lucid 10.04

The first beta for the latest Ubuntu is out, so I’m running it already. Aside from the strange window controls, it seems good so far. One of my first tasks was to make my gorgeous Logitech MX Revolution mouse work properly. Out of the box is… almost, just one little thing to solve – the “media wheel” by your thumb does nothing.

First, install xautomation and xbindkeys
sudo aptitude install xautomation xbindkeys
Xautomation is a program that can simulate key presses or mouse clicks when it’s run, and xbindkeys allows you to run a script when a specific button is pressed. Since Ubuntu doesn’t know about the buttons on the mouse, we’ll fake them!

Thanks to cecilx22 on ubuntuforums, I know the buttons of the MX Revo:
# Mappings for keys for MX Revo
# b:1 - left mouse button
# b:2 - left and right mouse button together
# b:3 - right mouse button
# b:4 - mouse wheel up
# b:5 - mouse wheel down
# b:6 - mouse wheel left
# b:7 - mouse wheel right
# b:8 - back button
# b:9 - forward button
# b:10 - -none-
# b:11 - -none-
# b:12 - -none-
# b:13 - media wheel up
# b:14 - -none-
# b:15 - media wheel down
# b:16 - -none-
# b:17 - media wheel press

So it’s 13 and 15 we’re interested in. Fire up a text editor – gedit is fine, or something hardcore and command line. You’re editing a file called ~/.xbindkeysrc – don’t forget that it won’t show up in your home directory as files starting with a dot are hidden unless you press ctrl+alt+h. Here’s the contents of my .xbindkeysrc:
#Media Scroll Wheel Up
"/usr/bin/xte 'keydown Control_L' 'key Page_Down' 'keyup Control_L' &"
b:13

#Media Scroll Wheel Down
"/usr/bin/xte 'keydown Control_L' 'key Page_Up' 'keyup Control_L' &"
b:15

The command when button 13 is triggered is Ctrl+Page_Down – notice how you have to say press and release for each button – and Ctrl+Page_Up for button 15. This means that the thumb wheel moves through tabs in your browser and page up/down in text files – perfect!

One last thing – to make this happen every time you start up, go to System > Preferences > Startup Applications. There you’ll need to add a new program, xbindkeys to startup.

Enjoy the new mouse – everything else works exactly as I want: browser back/forward, search button, middle click, side scroll. One thing to investigate if your scroll wheel isn’t doing what you want is revoco, which is a tiny program for just that one thing, though I don’t need it.


Update: (May 2011) I have used this same setup on the newer versions of Ubuntu – 10.10 Maverick Meercat and 11.04 Natty Narwhal – with complete success.