Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › [FAQ] Getting Mouse Side Buttons to work in Linux
New Posts  All Forums:Forum Nav:

[FAQ] Getting Mouse Side Buttons to work in Linux

post #1 of 32
Thread Starter 
There is more than one way to getting your extra mouse buttons to work in Linux. However the results vary from mouse to mouse, and there is no guarantee that any of these tricks will work.

First off if you like to use those extra side buttons to navigate in a browser( Example: back and forward). Then you might find that firefox already does this for you. This is because firefox has that feature hardcoded in. So it may work from the start for you. If not then here is something you can try.

You will have to make some edits to your xorg.conf file. So before you make ANY changes to xorg.conf make sure to make a backup of it in case you mess up or it doesn't work you can restore your original configuration.
To backup your current configuration
Code:
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
To restore the backup file then:
Code:
sudo mv /etc/X11/xorg.conf.backup /etc/X11/corg.conf
So open up a terminal and type: sudo gedit /etc/X11/xorg.conf

Find the section that looks like this:

Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
Option "CorePointer"
Option "Device" "/dev/input/mice"
Option "Protocol" "ImPS/2"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "true"
EndSection


It should look something like that.

First thing you can change is to comment out the line that says Option "Emulate3Buttons" "true". Since your mouse probably has a scroll wheel.
So it would now look like this: #Option "Emulate3Buttons" "true"

Next, make sure the Driver Xorg is using is the “mouse” driver. This is already correct in the above example code.

You can leave the Option “CorePointer” there, and the same with the Option “Device”. You do NOT want to change this if your mouse is already working. However, if your mouse is not working then you would want to change the location path (Example of other location paths you might try: /dev/mouse, /dev/input/mouse)

The next thing you will want to change is the Option “Protocol”. You will want to replace “ImPS/2” (or what ever is there) with “ExplorerPS/2”.
So the line would look something like this: Option "Protocol” “ExplorerPS/2”

Now you want to add the follow option in with the others:
Option “Buttons” “7”
The number of buttons depends on the number of buttons on your mouse, but remember that the scroll wheel counts as 3.

Make sure the option “ZAxisMapping” is present and has the parameter “4 5”.

If your mouse has two scroll wheels or a mouse that has a scroll that tilts side to side then you can try the parameter “4 5 6 7”. So either:
Option “ZAxisMapping” “4 5”
-OR-
Option “ZAxisMapping” “4 5 6 7”
(depending on your needs)

Also one other thing you can add is the resolution, that is if your mouse supports a high resolution, like most current gaming mice do.

Just add: Option “Resolution” “1800” (the 1800 can be what ever the highest you mouse can support, for mine thats 1800).


That is all for the xorg.conf file so save it, but before you restart Xorg, you still should do a few more things to make your life easier.

Using you favorite simple text editor (Example: vi, vim, nano, gedit, kate) open a new text document and type: pointer = 1 2 3 4 5 6 7
Now save this text file as .xmodmap and save it in your home directory (Example: /home/username).(Remember “username” needs to be replaced by your real username)

Now if your a KDE user, you can do the following:

Add the following into a new text file: xmodmap ~/.xmodmap

and save it as startup.sh is the following directory: /home/username/.kde/Autostart
And in a terminal type: chmod +x /home/username/.kde/Autostart/startup.sh

Now the command: xmodmap ~/.xmodmap, is run everytime you log into KDE.


For Gnome users, you should be able to do the same instructions for the KDE users, but just change the location where you save the file startup.sh. However I am not that similar with Gnome, so I am not sure if there is an Autostart folder or not.

If you are not a KDE user and a confused Gnome user, then you can try the following.

See if the file .xinitrc exist in one of the two following locations: /root , or /home/username

To see if its there, try running the following two commands in the terminal:
sudo ls -a /root/ | sed -n /.xinitrc/p <-need to be root, so thats why sudo is added.
ls -a ~/ | sed -n /.xinitrc/p <-run as your normal user

If one of these locations has the .xinitrc file then open it in your favorite text editor: (NOTE: If the file .xinitrc is in both of these locations, then you can either edit both of them or the one that is in the users account home that you log into the most. Changing it in one location doesn't change it in the other).

Example (in a terminal): kate /path/.xinitrc (add sudo to the front if .xinitrc is in the directory /root)

Now add the following line to .xinitrc: xmodmap /path/to/file/.xmodmap

Save .xinitrc. The file .xinitrc is ran everytime Xorg is started.


NOTE: If you are a KDE user and you have a .xinitrc file, then it does not matter which of the above methods you choose. Just don't add it to both.



Now that this is all done you can restart Xorg (either by login out and then back in or by pressing <ctrl>+<alt>+<backspace key>).

Now in a web browser you should hopefully be able to use the thumb buttons on your mouse as back and forward buttons.

If you wanted to use the extra mouse buttons to execute a program then look into a program called IMWheel.

Home Page: http://imwheel.sourceforge.net/

Some one else's Howto on it can be seen here: http://legroom.net/howto/mouse

I didn't feel like writing anything up on that since I have little experience with IMWheel.

Some thing that might help you if you want to use IMWheel: http://imwheel.sourceforge.net/imwheelrc

Again I just want to say that there is no guarantee that any of the above will work, but I am able to have my thumb buttons on my mouse work as back and forward. Mouse is a Logitech MX518.
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
post #2 of 32
I tried this method here:

http://forums.fedoraforum.org/archiv...p/t-27470.html

It worked half-assedly. It gave me forward/backward on my mouse, but only via the scroll wheel (up on the scroll wheel = back one page, down on scroll wheel = forward one page).

Any way to mod that to get it to work for the side buttons? That method is the closest i got to getting this to work.
post #3 of 32
Thread Starter 
You can try playing around with this option: Option "ZAxisMapping" "4 5"

Could try:
Option "ZAxisMapping" "4 5 6 7"
Option "ZAxisMapping" "6 7 4 5"
ect..
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
post #4 of 32
Quote:
Originally Posted by dangerousHobo View Post
There is more than one way to getting your extra mouse buttons to work in Linux. However the results vary from mouse to mouse, and there is no guarantee that any of these tricks will work.

First off if you like to use those extra side buttons to navigate in a browser( Example: back and forward). Then you might find that firefox already does this for you. This is because firefox has that feature hardcoded in. So it may work from the start for you. If not then here is something you can try.

You will have to make some edits to your xorg.conf file.

So open up a terminal and type: sudo gedit /etc/X11/xorg.conf

Find the section that looks like this:

Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
Option "CorePointer"
Option "Device" "/dev/input/mice"
Option "Protocol" "ImPS/2"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "true"
EndSection


It should look something like that.

First thing you can change is to comment out the line that says Option "Emulate3Buttons" "true". Since your mouse probably has a scroll wheel.
So it would now look like this: #Option "Emulate3Buttons" "true"

Next, make sure the Driver Xorg is using is the “mouse†driver. This is already correct in the above example code.

You can leave the Option “CorePointer†there, and the same with the Option “Deviceâ€. You do NOT want to change this if your mouse is already working. However, if your mouse is not working then you would want to change the location path (Example of other location paths you might try: /dev/mouse, /dev/input/mouse)

The next thing you will want to change is the Option “Protocolâ€. You will want to replace “ImPS/2†(or what ever is there) with “ExplorerPS/2â€.
So the line would look something like this: Option "Protocol†“ExplorerPS/2â€

Now you want to add the follow option in with the others:
Option “Buttons†“7â€
The number of buttons depends on the number of buttons on your mouse, but remember that the scroll wheel counts as 3.

Make sure the option “ZAxisMapping†is present and has the parameter “4 5â€.

If your mouse has two scroll wheels or a mouse that has a scroll that tilts side to side then you can try the parameter “4 5 6 7â€. So either:
Option “ZAxisMapping†“4 5â€
-OR-
Option “ZAxisMapping†“4 5 6 7â€
(depending on your needs)

Also one other thing you can add is the resolution, that is if your mouse supports a high resolution, like most current gaming mice do.

Just add: Option “Resolution†“1800†(the 1800 can be what ever the highest you mouse can support, for mine thats 1800).


That is all for the xorg.conf file so save it, but before you restart Xorg, you still should do a few more things to make your life easier.

Using you favorite simple text editor (Example: vi, vim, nano, gedit, kate) open a new text document and type: pointer = 1 2 3 4 5 6 7
Now save this text file as .xmodmap and save it in your home directory (Example: /home/username).(Remember “username†needs to be replaced by your real username)

Now if your a KDE user, you can do the following:

Add the following into a new text file: xmodmap ~/.xmodmap

and save it as startup.sh is the following directory: /home/username/.kde/Autostart
And in a terminal type: chmod +x /home/username/.kde/Autostart/startup.sh

Now the command: xmodmap ~/.xmodmap, is run everytime you log into KDE.


For Gnome users, you should be able to do the same instructions for the KDE users, but just change the location where you save the file startup.sh. However I am not that similar with Gnome, so I am not sure if there is an Autostart folder or not.

If you are not a KDE user and a confused Gnome user, then you can try the following.

See if the file .xinitrc exist in one of the two following locations: /root , or /home/username

To see if its there, try running the following two commands in the terminal:
sudo ls -a /root/ | sed -n /.xinitrc/p <-need to be root, so thats why sudo is added.
ls -a ~/ | sed -n /.xinitrc/p <-run as your normal user

If one of these locations has the .xinitrc file then open it in your favorite text editor: (NOTE: If the file .xinitrc is in both of these locations, then you can either edit both of them or the one that is in the users account home that you log into the most. Changing it in one location doesn't change it in the other).

Example (in a terminal): kate /path/.xinitrc (add sudo to the front if .xinitrc is in the directory /root)

Now add the following line to .xinitrc: xmodmap /path/to/file/.xmodmap

Save .xinitrc. The file .xinitrc is ran everytime Xorg is started.


NOTE: If you are a KDE user and you have a .xinitrc file, then it does not matter which of the above methods you choose. Just don't add it to both.



Now that this is all done you can restart Xorg (either by login out and then back in or by pressing <ctrl>+<alt>+<backspace key>).

Now in a web browser you should hopefully be able to use the thumb buttons on your mouse as back and forward buttons.

If you wanted to use the extra mouse buttons to execute a program then look into a program called IMWheel.

Home Page: http://imwheel.sourceforge.net/

Some one else's Howto on it can be seen here: http://legroom.net/howto/mouse

I didn't feel like writing anything up on that since I have little experience with IMWheel.

Some thing that might help you if you want to use IMWheel: http://imwheel.sourceforge.net/imwheelrc

Again I just want to say that there is no guarantee that any of the above will work, but I am able to have my thumb buttons on my mouse work as back and forward. Mouse is a Logitech MX518.
A little to much for some noobs,
and as for copy, paste or the internet shortcut keys, try xbindkeys
you could even use your ir remote w/o lirc
Atlantis
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Athlon(tm) 64 X2 Dual Core Processor 6400+ Asus M2N-SLI deluxe bfg tech geforce 7600 gt oc 1 GB corsair xms ddr2 
Hard DriveOSMonitorKeyboard
80 GB sata +320 GB sata Gentoo:win2k3 ACER micro wireless 
PowerCaseMouse Pad
350w need 600w TT sviking the "blue mouse pad" 
  hide details  
Reply
Atlantis
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Athlon(tm) 64 X2 Dual Core Processor 6400+ Asus M2N-SLI deluxe bfg tech geforce 7600 gt oc 1 GB corsair xms ddr2 
Hard DriveOSMonitorKeyboard
80 GB sata +320 GB sata Gentoo:win2k3 ACER micro wireless 
PowerCaseMouse Pad
350w need 600w TT sviking the "blue mouse pad" 
  hide details  
Reply
post #5 of 32
Quote:
Originally Posted by dangerousHobo View Post
You can try playing around with this option: Option "ZAxisMapping" "4 5"

Could try:
Option "ZAxisMapping" "4 5 6 7"
Option "ZAxisMapping" "6 7 4 5"
ect..
Argh, other combos end up in either my other mouse buttons not having any function or my scroll wheel doing the forward/backwarding. If it helps, i have an MX518. It's got 2 clicks, 1 wheel button, 1 up wheel, 1 down wheel (same wheel, just its 3 functions), 1 sensitivity up button, 1 sensitivity down button and 1 "window switcher" button. So should i put it as a 10 button mouse or 8 button mouse or keep it as a 7 button? I mean could it be reading the buttons wrong since i don't have exactly 7 buttons like i'm specifying?
post #6 of 32
Nice work Hobo, I have a Razer Diamondback (waste of money maybe? not as much as the Copperhead.) and all the buttons have always worked from install except that the right side buttons act as a scroll wheel, I heard somewhere that this is also the default action in Windows and is changed with the Razer software. I am fairly confident my xorg.conf is correct (I created it as it is before seeing this article but it seems to fit with the info here)
Code:
Section "InputDevice"
    # generated from data in "/etc/conf.d/gpm"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Name" "Razer Diamondback"
    Option         "Vendor" "Razer"
    Option         "CorePointer"
    Option         "Protocol" "ExplorerPS/2"
    Option         "Device" "/dev/input/mice"
    Option         "ZAxisMapping" "4 5"
    Option         "Buttons" "9"
    Option         "ButtonMapping" "1 2 3 4 5 6 7 8 9"
    Option         "Resolution" "1600"
    Option         "SampleRate" "1000Hz"
EndSection
I found out how to do this on some Ubuntu and Fedora forums, and I created the file etc/X11/xinit/xinitrc.d/mouse.sh, made it executable and added

EDIT: I have read that xorg only supports 7 button mice.
HAL9000
(13 items)
 
  
CPUMotherboardGraphicsRAM
Athlon 4800+ X2 "Toledo" MSI K8N Neo4 Platinum MSI GeForce 7900GS 512MB Overclock Edition 2GB OCZ Platinum DDR400 
Hard DriveOSMonitorPower
2xSeagate Barracuda 250GB 7200RPM 3.0Gb/s SabayonLinux x86 3.4 Optiquest Viewsonic Q20wb Antec Earthwatts 500W 
CaseMouse
Thermaltake Tsunami Dream Razer Diamondback 
  hide details  
Reply
HAL9000
(13 items)
 
  
CPUMotherboardGraphicsRAM
Athlon 4800+ X2 "Toledo" MSI K8N Neo4 Platinum MSI GeForce 7900GS 512MB Overclock Edition 2GB OCZ Platinum DDR400 
Hard DriveOSMonitorPower
2xSeagate Barracuda 250GB 7200RPM 3.0Gb/s SabayonLinux x86 3.4 Optiquest Viewsonic Q20wb Antec Earthwatts 500W 
CaseMouse
Thermaltake Tsunami Dream Razer Diamondback 
  hide details  
Reply
post #7 of 32
Tried this under Ubuntu Gnome...crashed my X environment right after I logged out.
post #8 of 32
Thread Starter 
Make sure you didn't make a syntax error, just one simple error will crash X.
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
post #9 of 32
Quote:
Originally Posted by dangerousHobo View Post
Make sure you didn't make a syntax error, just one simple error will crash X.
I found that out the hard way I had to reinstall. I didn't know what else to do. Its ok though. I was looking for an excuse to try out Mandriva
post #10 of 32
Thread Starter 
Sorry to make you have to reinstall.
B/c of your problem though, it made me notice that I left an important part out of the FAQ....backing up xorg.conf first.
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › [FAQ] Getting Mouse Side Buttons to work in Linux