A weirdly named site with lots of boring content!

Sat 22 Dec 2007

xorg.conf Settings for a 5-button Mouse in Linux

Replace the existing entry for your mouse in /etc/X11/xorg.conf with the following and restart X:

Section "InputDevice"
   Identifier   "Configured Mouse"
   Driver      "mouse"
   Option      "CorePointer"
   Option      "Device"   "/dev/input/mice"
   Option      "Protocol"   "ExplorerPS/2"
   Option      "Emulate3Buttons"   "false"
   Option      "Buttons"   "7"
   Option      "ZAxisMapping"   "4 5"
   Option      "ButtonMapping"   "1 2 3 6 7"
   Option      "Resolution"   "300"

Linux should now be able to respond to the 'forward' and 'back' buttons on your mouse. Firefox should not need any further configuration, however few other apps make use of these buttons out of the box. This is where imwheel comes in.

Install this and you can map the extra mouse buttons to different key-presses in different applications. For Debian and Ubuntu distros, do sudo apt-get install imwheel.

It installs to /etc/X11, where you'll find a couple of config files living in a subdirectory called imwheel. Set up any key bindings in imwheelrc. The first rule-set in this file that matches the current window will apply - and no further rule-sets will be read.

Each rule-set is preceded by a regular expression defining which application windows the set applies to - this must match against the window's name or title. Rules to configure the buttons then follow. These take the form:

Modifier, Mouse key, Mapped key[, Repeat]

where Mouse key determines which mouse key you are defining, and is either Up or Down (the scroll wheel), or Left or Right (back/forward buttons). Set Modifier to a modifier key, eg Control_L, Alt_L, Shift_R, to define key combos that require the corresponding modifier key to be held at the same time as the mouse button. Or set this to None to define actions for when mouse buttons are pressed on their own. Here's a typical config file:

None, Left, Control_L|V
None, Right, Control_L|X

None, Left, Control_L|V
None, Right, Control_L|X

None, Left, Up
None, Right, Down

None, Left, Alt_L|Left
None, Right, Alt_L|Right

None, Left, Alt_L|Left
None, Right, Alt_L|Right
Leave Comment

/xkcd/ Memorable Quotes