Update 7/18/2010


In the past I always shut down my machine, never let it got to sleep or hibernate, so I never dealt with the issue of what happens to the MX when you come back from one of those state(hint: not what you'd like).  If your wheel resets to free spin after waking up, drop the below script in /etc/pm/sleep.d, changing the location of revoco if necessary:
Code
#!/bin/bash
case "$1" in
hibernate|suspend)
/usr/bin/revoco click
;;
thaw|resume)
/usr/bin/revoco click
;;
*) exit $NA
;;
esac


Many an article and forum thread has been written on the subject of Linux and the MX Revolution.  Today I add one more to the pool.  After much research and many live cd sessions, I settled on Linux Mint, a derivative of Ubuntu.  For the most part everything went very smooth, much more so than I remember from the last time I tried Linux.
 
After getting everything setup just the way I liked it, I noticed one thing that would bother me if it wasn't corrected.  Few of my extra mouse buttons worked.  I have a Logitech MX Revolution and in Windows I used the thumb wheel as my volume control, and the search button was play/pause.  However here they were dead except the search button which helpfully popped up an error message on every press.  Also I noticed that the scroll wheel was set so that if you click the wheel, it alternates between click and free spin.  This robbed me of the middle click functionality that I use in my browsing to open links in new tabs and to also close open tabs.  It took some time, but after wading through numerous blogs and message boards, I was able to put it all together and get my mouse working correctly. 
 
Overview
Since i'm on Mint, these instructions apply to it and will probably work on most distros with few modifications(yum instead of apt-get or aptitude, etc).  On older distros you may have to install the evdev driver, but most come with it by default now.  If you're using an older distro, and you can't get the following to work, skip down to the bottom and see if the extra setup helps.  You'll also be needing revoco, a utility that manipulates the Revolution's wheel spin setting(free spin, click-to-click), and xbindkeys, a utility to map commands to mouse buttons.

Installing Packages
Your package names may vary, so try searching the repos for the exact name of the package to install.  First lets get xbindkeys, which does the actual button to command mapping:
Code
sudo aptitude install xbindkeys

There's also a front end for configuring xbindkeys(conveniently called "xbindkeys-config").  You can install it if you prefer a gui for configuring, but for me manually editing the config file was faster and easier, and as such, won't be covered here.  Then you'll need to get revoco which sets up the middle wheel to either free spin or click-to-click.  If the default behavior  doesn't bother you, you can skip this step.  You can download the source from http://goron.de/~froese/revoco/.  At the time of writing, the current version is 0.5.  You'll need to extract the source somewhere then cd to that directory.  Once there, compile the source:

Code
$ make
cc -Os -DVERSION=\"0.5\" -Wall   -c -o revoco.o revoco.c
cc -s  revoco.o   -o revoco

Configuring
Now that everything is installed, we can start setting up the mouse.  For me the configuration was minimal, I only setup 4 buttons.  This involves editing Xorg.conf(You can skip this step if you didn't have to install evdev), setting the wheel scroll state(Again, you can skip this step if you don't care) and finally setting up binds for the keys.  I copied my revoco binary to the /usr/bin directory so I didn't have to fool around with cd'ing to the directory and I can just call it from wherever I am.  You can do the same, otherwise you'll have to cd to the directory first.  Configure revoco to your liking, for me it was setting it to click-to-click(people not putting it in /usr/bin, use "./revoco":

revoco click


Just calling revoco with no arguments gives you a run down of the available commands, such as getting the battery status, setting to free spin or click-to-click, or getting the current wheel state.  Now we actually get to binding the buttons.  First we need to generate the configuration file xbindkeys uses:

Code
xbindkeys --defaults > ~/.xbindkeysrc

This tells xbindkeys to display the default configuration, then redirect the output to the file ".xbindkeysrc" in our home folder(/home/*user*/.xbindkeysrc).  You could skip this step and just manually create a file named '.xbindkeysrc' in your home directory and paste in the below text or type up your own.  You can then open and edit the file using whatever text editor you like.  The default configuration is pretty verbose, I cut out all the unnecessary comments and the example binds at the bottom and added my own:

Code
#Middle button click(mute)
"amixer set Master toggle"
b:17

#Middle button forward(volume up)
"amixer set Master 2+"
b:13

#Middle button click(mute)
"amixer set Master 2-"
b:15

#Play/Pause button
"rhythmbox-client --play-pause"
c:225


Here, I configured my thumb wheel click to mute(via toggle), the push to increase the volume, pull to decrease it and the search button to act as my play/pause button.  Your audio control commands will vary depending on the driver you use, for me it's amixer with the ALSA driver.  I also use rhythmbox as my music player and it's associated console commands to control the playback.  The "b:xx" indicates the mouse button number, which you can get from the list at the bottom of this article, along with some other details.  The "c:" is the code for the search button on the top of the mouse, since Linux views it as a keyboard key rather than a mouse button, 225 being it's code, and "c" being the modifier to indicate you want to put in a straight keycode.  You can then run "xbindkeys" from the console and try out your binds.  Any changes you make to the config file take effect in real time so there's no need to keep calling the program every time you make a change.  Now that you're happy with your binds, it's time to set it up so they load on every boot.  Start up the startup application manager for your distro, for Mint users, go to "Menu -> Control Center -> Startup Applications".  Add a new entry with the command "xbindkeys".  That's it, now save it and reboot.  If you find that your middle wheel reverts to free spin on rebooting, you will need to also add a startup entry for "revoco click"(this requires revoco be placed in "/usr/bin/").  It'll also revert if your mouse loses it's connection with the pc(if the battery dies, mouse goes out of range, you turn it off via the switch on the bottom, etc), but I don't have a work around for that.

Legacy

Certain older distros might not have the evdev driver installed by default and in turn would need to edit Xorg.conf to use the new driver.  If you're using an older version, and the above alone don't get it working, try the following.  First let's check if we have the evdev driver installed.

Code
cat /var/log/Xorg.0.log | grep -i loadmodule


If one of the listed modules is "evdev", then you've got it installed.  If not, install it using whatever package manager you use:

Code
sudo aptitude install xserver-xorg-input-evdev


You'll now have to configure Xorg.conf to use the driver.  The first thing to do is to get the device information:

Code
cat /proc/bus/input/devices

I: Bus=0003 Vendor=046d Product=c51a Version=0111
N: Name="Logitech USB Receiver"
P: Phys=usb-0000:00:0b.0-6.3/input0
S: Sysfs=/devices/pci0000:00/0000:00:0b.0/usb2/2-6/2-6.3/2-6.3:1.0/input/input5
U: Uniq=
H: Handlers=mouse1 event5
B: EV=17
B: KEY=ffff0000 0 0 0 0
B: REL=143
B: MSC=10


Find the section relating to the mouse, if you have more than one entry, just go with the first.  In particular you'll want to note the "P: Phys" line.  Now open /etc/X11/xorg.conf and comment out the "InputDevice" section for your mouse and edit it accordingly:

Code
#Section "InputDevice"

    # generated from default
    #Identifier     "Mouse0"
    #Driver         "mouse"
    #Option         "Protocol" "auto"
    #Option         "Device" "/dev/psaux"
    #Option         "Emulate3Buttons" "no"
    #Option         "ZAxisMapping" "4 5"
#EndSection

Section "InputDevice"
    Identifier    "MX Revolution"        #This can be whatever you want
    Driver        "evdev"            #The driver we downloaded
    Option        "Phys"    "usb-*/input0"    #The above device info
    Option        "CorePointer"
EndSection


For the "Phys" option, put in your specific information(ex: if your input is "input1" set Phys to "usb-*/input1").  The Identifier can be whatever you like, we'll be referencing it in a moment.  Notice the inclusion of the evdev driver.  Go to the top of your xorg.conf and find "ServerLayout".  You can comment out any existing reference to a mouse and add in our new one:

Code
Section "ServerLayout"
    Identifier     "Default Layout"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
#   InputDevice    "Mouse0" "CorePointer"
    InputDevice    "MX Revolution" "CorePointer"    #Input the "Identifier" from the InputDevice section
EndSection


You should be set from here.  Either restart X or reboot your machine.


Etc.
I can only say these are the numbers for the MX Revolution, but even then i've seen some tutorials list out different numbers than what i've got.  If you're not getting the results you expect with a button you setup, run "xev" from the console and press each button, paying attention to the output.  You're looking for ButtonPress or ButtonRelease events, and inside them the "button" property which indicates the button number that you'll use when assigning binds:

Code

brandon@minty ~ $ xev

ButtonPress event, serial 33, synthetic NO, window 0x3600001,
    root 0x13c, subw 0x0, time 8383250, (82,82), root:(2045,583),
    state 0x10, button 2, same_screen YES


Here, i've clicked the middle wheel, indicated by the "button 2" property.  I can then take that number and map it to a command, for me it was muting the volume.  Bellow are the corresponding numbers for my mouse, yours may be different.


Code
Right button------------1
Left button-------------3
Middle wheel click------2
Middle wheel push-------4
Middle wheel pull-------5
Middle wheel left-------6
Middle wheel right------7
Thumb button back-------8
Thumb button forward----9
Thumb wheel push--------13
Thumb wheel pull--------15
Thumb wheel click-------17
Search button-----------keycode 225