Map Mouse Buttons in Fedora 18

Long gone are the old two button trackball mouses, I’ve gone through a few laser mouses recently with 5+ buttons.

Long ago I recall with Windows we had the custom firmware built from Logitech or Razor. Within Linux we don’t have that luxury (or dead weight) but we have our nifty tools and workarounds.

Here’s the quick how to:

sudo yum install xbindkeys xautomation  

xbindkeys – This is what maps key binds to commands
xautomation – This installs Xev and Xte (among other tools). Xev is used to find your mouse button and Xte is used to send keyboard commands.

In terminal power run xev

xev  

A small window will open, click your mouse button in the box and you should get an output like this, my button key is 8:

ButtonRelease event, serial 31, synthetic NO, window 0x1e00001,  
    root 0x9e, subw 0x1e00002, time 142563202, (50,51), root:(51,142),
    state 0x10, button 8, same_screen YES

Lets create our xbindkeys config

xbindkeys --defaults > ~/.xbindkeysrc  
gedit ~/.xbindkeysrc  

You can remove a few of the other example configs, this is what I have setup. I have mapped mouse button 8 and 9 to switch Gnome Desktops.

# Command
#  Button/Mouse

"xte 'keydown Control_L' 'keydown Alt_L' 'key Up' 'keyup Control_L' 'keyup Alt_L'" 
  b:9

"xte 'keydown Control_L' 'keydown Alt_L' 'key Down' 'keyup Control_L' 'keyup Alt_L'" 
  b:8

xte will send the keys, set the key down and then back up. Take a look at “man xte” for further info.

Last thing is to set it to run on Startup:

gnome-session-properties  

Add xbindkeys to run on startup and wallah.

I thought I’d keep this post a little simpler but what I actually have setup is is a bash script to check what applications I have running and from that bash script I will alternate the keys there. Eg, if I’m running teamspeak.

comments powered by Disqus