Back button to middle mouse button

kdemousex11xmodmap

I would like to map "Back" button (xev shows it as "button 7") of my mouse (A4Tech X-7) to act as a middle mouse button. Is there a way to do this? I'm lost in google, finding only how to map buttons to keyboard shortcuts with xbindkeys and etc.

  • OS: Centos 6.3 (x86_64)
  • DE: KDE 4.3.4

P.s. I can switch (with xmodmap) "Back" button with middle button with no problems, but is there a way to have both them act as a middle mouse button?

Best Answer

You cannot map two physical buttons to the same logical button. All you can do is swap the buttons (echo 'pointer 1 7 3 4 5 6 2' | xmodmap -). This is a low-level limitation of X11. As stated in the documentation of XSetPointerMapping:

However, no two elements can have the same nonzero value, or a BadValue error results.

The best you can do is to use a program like xbindkeys to send a fake button 2 press when button 7 is pressed. In .xbindkeysrc:

"xdotool mousedown 2"
  b:7
"xdotool mouseup 2"
  b:7 + Release
Related Question