The Logitech Performance MX mouse is an absolutely exceptional computer mouse. Ubuntu is an exceptional Linux operating system. It’s only natural that you would want to use these two great pieces of technology together. By default, however, they are not fully compatible with each other. Sure your normal mouse functions will work fine right out of the box, but the special buttons, like the forward and back buttons, will take a tad more effort to get working though. Luckily, however, the process is fairly straightforward.
Step 1: Find Mouse Button Codes
The first step is to figure out what the codes for the various buttons on your mouse are. to do this we are going to use a program called xev. Open up the terminal and run:
This will open up a little window with a square in it. Place your mouse in the square and hit the button that you wish to get the code for. In the terminal you will notice a bunch of output. Find the line that is labeled ButonRelease. This will be a block of code that looks something like this:
The part we are interested in is the section that says button 8. That means that the code for this particular mouse button is 8. Repeat this step for the back, forward, magnify, and special button on the mouse. Doing so will most likely give you these results:
Step 2: Install xbindkeys
The way we are going to map the mouse keys to Ubuntu is by using a combination of the xbindkeys program and the xautomation program. In this step we are going to install the xbindkeys program. To do this simply run the following command in the terminal:
sudo apt-get install xbindkeys
Step 3: Setup xbindkeys
Next we need to set up the xbindkeys program by creating an initial config file. This can be done simply by running:
xbindkeys --defaults > $HOME/.xbindkeysrc
Step 4: Map the Keys
Now is where we actually work some magic by mapping the mouse keys. We are going to do this by using the program xautomaiton (xte) to simulate a key-press when a particular mouse button is pushed. For example, when we press the forward mouse button it is going to trigger the Ctrl+Right Arrow key combination.
Start by opening up the configuration file:
For the back and forward buttons we will add the following code to the file:
# Back "xte 'keydown Alt_L' 'key Left' 'keyup Alt_L'" b:8 # Forward "xte 'keydown Alt_L' 'key Right' 'keyup Alt_L'" b:9
Let’s take a moment to examine what the above command says. The xte simply tells xbindkeys to use the xautomation program. We are then stating that when Ubuntu receives a key-press from button 8 (b:8) to simulate a key press of the left Alt+Left arrow key. The syntax is similar for the forward button.
Saving this to the file will get the back and forward buttons working fully on the mouse. The other two buttons, however, are where things become slightly less seamless. Neither Ubuntu 11.04 or the upcoming 11.10 release has a feature to display all the currently open windows, which is the default action of the special button in Microsoft Windows. You can program this button to do whatever you like using the above methods, but the one I’m going to show you is how to trigger the expo plugin.
If you don’t know what the expo plugin is it’s the list of workspaces that you get from pressing Super+S. To map this functionality to the special key use the following code:
# Expo "xte 'keydown Super_L' 'key s' 'keyup Super_L'" b:10
The only button we haven’t mapped so far is the zoom button. I’m yet to find a way to make the zoom button function on Ubuntu in a similar fashion as it does on Windows . As a result I can only suggest using the above methods to map it to do some other task. If anyone happens to know a way of gaining the zoom functionality please let me know!
Step 5: Install xte
Now we need to actually install the xte (xautomation) program. You can do this by running the following command in the terminal:
sudo apt-get install xautomation
Step 6: Add xbindkeys to the List of Startup Programs
The final step is to set xbindkeys to start automatically with Ubuntu. To do this go to System Settings->Startup Applications
Once you complete these relatively simple steps all of the special keys on your Logitech Performance MX mouse should be fully functional. As always if you have any questions please don’t hesitate to post in the comment section below!