Multibutton mouse support in Linux

Do you have a fancy mouse with more than 3 buttons? No? Didn't think so. Stop reading.

Yes, you do? OK, keep reading. This is one of those things that Just Works in Windows but unfortunately requires some futzing in Linux. But, if you're enough of a nerd to have a multibutton mouse in the first place, then you probably won't mind. The good news is it's pretty simple.

"There are already lots of How-To's for this online. Why write another one?" Because all the other ones either don't work with Kubuntu Fiesty Fawn, or they don't explain what they're doing. This How-To will try to explain as it goes along; if your system is slightly different then this tutorial should work anyway.
First you have to open /etc/X11/xorg.conf. Be REALLY CAREFUL with this file. Save a copy first.

Find the mouse section. Make it look like this:

Section "InputDevice"

Identifier "Configured Mouse"
Driver "mouse"
Option "CorePointer"
Option "Device" "/dev/input/mice"
Option "Protocol" "ExplorerPS/2"
Option "Buttons" "9"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "no"

EndSection

Protocol: Make sure it says "ExplorerPS/2" regardless of what kind of mouse you actually have. Just works better this way.

Buttons: I have a 7-button mouse, but Linux thinks I have a 9-button mouse:

  1. Left button
  2. Middle
  3. Right
  4. Scroll wheel up
  5. Scroll wheel down
  6. Nothing
  7. Nothing
  8. Left side button
  9. Right side button

Other tutorials ask you to mess around with xmodmap or xorg.conf to deal with the "missing" 6 & 7 buttons, but it's not necessary.

ZAxisMapping: this is for your scroll wheel. Leave it alone.

Emulate3Buttons: If you have a scroll wheel, then you have a middle mouse button (try pressing it instead of scrolling). If you don't have a scroll wheel but you still have two mouse buttons (like on a laptop), you can emulate that middle button by pressing right & left at the same time. If you have a fancy multibutton mouse then you don't need this feature so you can turn it off ("no").

Install some additional software:

sudo apt-get install xev imwheel

Open up a console and type xev. It will pop up a new window. Move the mouse into this window. Figure out what your side buttons are. In my case they're 8 & 9. For you they might be different (maybe 6 & 7). Type ctrl-c to close xev.

imwheel gives names to these mouse button numbers:

Button Number: Name in imwheelrc
4: Up
5: Down
6: Left
7: Right
8: Thumb1
9: Thumb2
10: ExtBt7
11 : ExtBt8

Since my side buttons are 8 & 9, imwheel names them Thumb1 & Thumb2. I will configure imwheel accordingly:
kate .imwheelrc

Add this code:

".*"
None, Thumb1, Alt_L|Left
None, Thumb2, Alt_L|Right

"(null)"
None, Thumb1, Alt_L|Left
None, Thumb2, Alt_L|Right

If your side buttons are 6 & 7 then you'll want to map Left & Right instead of Thumb1 & Thumb2. Other tutorials suggest you remap mouse mouse using xmodmap, but that confused the hell out of me and it's not necessary.

Make sure imwheel is running:

killall imwheel; imwheel

(You kill it first to make sure an older version isn't already running.)

Open a web browser and try it out! If it works and you like it, make sure it will load next time you reboot.

sudo kate /etc/X11/imwheel/imwheelrc

Fine the line IMWHEEL_START=0. Change it to IMWHEEL_START=1.

Enjoy!