Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Logitech m505 mouse, which works fine with my ubuntu 12.04. However, the middle button is so hard to press down that in windows I had assigned it to left scroll with the logitech driver. So if I was to open a link in a new tab, I'd pull the scroll button to the left. (I should also note that the mouse I have has a middle button that scrolls up and down, can be pressed down, and also can be "pulled" to left and right).

Can I do this with xbindkeys, for instance? I think I know all the info that I need about the mouse: numbers of buttons, device name, etc.

I'd appreciate if you could help.

share|improve this question
up vote 2 down vote accepted

I figured out how to do this.

First use xev to find out the "button numbers". Type xev in the terminal, and click on the buttons of your mouse in the newly opened white window. Many lines appear in the terminal, such as these:

ButtonPress event, serial 36, synthetic NO, window 0x3c00001,
root 0x15d, subw 0x3c00002, time 10181966, (30,51), root:(1208,104),
state 0x10, button 1, same_screen YES

The "button 1" is the number, in my case, for left-click.

I wanted to switch left scroll with middle button, which were 6 and 2 respectively.

The next step is to learn the id of the input device:

xinput list

Mine had such an entry for the Logitech mouse:

Logitech Unifying Device. Wireless PID:101d id=10   [slave  pointer  (2)]

Then, I type the following to map button 2 to 6, and vice versa, for the input device with id 10:

xinput set-button-map 10 1 6 3 4 5 2 7

This is only going to be temporary, and be gone when you reboot. To make it permanent, you could edit the xorg.conf file, but doing so caused problems for me, and the system did not boot. Instead, I created an entry in startup applications, writing the last xinput command as the command.

This has one drawback -- the id has to stay the same. However, I do not know when and why it changes, as mine seem to stay the same. If I was to guess, I'd say that plugging the usb receiver in another usb port could change the id. I am not sure.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.