Skip navigation.
Home
Now Shipping Version 7.0

Getting forward and backward mouse buttons to work.


Posts: 4

Here is how I got the forward and backward mouse buttons to work in Firefox and other apps.

First, you need to have /etc/X11/XF86Config-4 set up properly. For this, you need to know how many buttons are on your mouse. Since both scroll wheel up and down count as sepparate buttons, the button number will be at least two more than what you would expect. For example, a standard three button scroll mouse is actually a five button mouse. My mouse is a bit more complicated. It has left, right, wheel, forward, backward, and some windowing button. Since the scroll wheel also tilts left and right, the total is 10. Everything here assumes 10 buttons, but the proceedure is the same for simpler mice.

You must have the mouse be the core pointer for xmodmap to work. So comment out the line
InputDevice "PS/2 Mouse" "CorePointer"
and uncomment the line
#InputDevice "USB Mouse" "CorePointer"
or whatever is appropriate to your specific setup.

Next change the inputdevice section so that it looks something like this:

Section "InputDevice"
Identifier "USB Mouse"
Driver "mouse"
Option "CorePointer"
Option "Device" "/dev/input/mice"
Option "Protocol" "ExplorerPS/2"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "9 10"
Option "Buttons" "10"
Option "Resolution" "800"
EndSection

I am not sure if CorePointer is necessary here since it is in the previously mentioned section. ZAxisMapping will always be your last two buttons, however many you may have. Resolution is optional. This indicates the sensitivity of your optical mouse. This will depend upon your particular one.

The next step is to remap your mouse buttons. X always assumes that the last two buttons are the scroll buttons. But alas this is not generally the case. I recommend running xev to make sure you know which buttons are which. Then create the following file so that the system maps the buttons correctly.

/etc/X11/Xmodmap
pointer = 1 2 3 6 7 9 10 4 5

For 7 button mice,
pointer = 1 2 3 6 7 4 5

The exact mapping will depend on the mouse of course. If you want the mapping to be user dependent, one can make ~/.Xmodmap.

Now that the machine knows the number of buttons and location of the wheel, we need to map the forward and back buttons. This can be done with imwheel.

apt-get install imwheel.

To have xmodmap run when you log in, do the following.
cp /usr/share/doc/imwheel/example/61imwheel_load-xmodmap /etc/X11/Xsession.d
This will run xmodmap with the global and local setting files.

Also, to have imwheel automatically run, you must change /etc/X11/imwheel/startup.config to look like this:

# Configuration file for setting imwheel startup parameters.

# Set this to "1" to make imwheel start with X.
IMWHEEL_START=1

# Specify the command line parameters to pass to imwheel.
# Simply uncomment the bottom line, and replace the default
# options with your own if necessary.
IMWHEEL_PARAMS="-b "67""

The last parameters depend on the mouse, but I believe the one above will work for most mice. To manually run imwheel, do
imwheel -k -b "67"

Okay, we are almost done. Different apps use different commands for navigation. So imwheel maps the forward and back buttons to different keystrokes depending upon the application. This is set up in /etc/X11/imwheel/imwheelrc. Each user can have their own ~/.imwheelrc. Many application settings are already in the file, but firefox and konqueror are missing. So add the following somewhere.

"^Firefox-bin$"
None, UP, Alt_L|Left
None, DOWN, ALT_L|Right

"^konqueror$"
None, Up, Control_L|Page_Up
None, Down, Control_L|Page_Down

The pipes, "|", allow for key combinations. One can string together many keys together if desired for more sophisticated mappings. The first line is a regular expression which imwheel tries to match with the app window name. If the name matches, it will use that mapping.

Restart X and enjoy the new functionality. I hope this has been a help. Please make any suggestions or comments.