Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 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?

share|improve this question
up vote 5 down vote accepted

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"
"xdotool mouseup 2"
  b:7 + Release
share|improve this answer
That's what I've thought. Anyway, thanks for nice reply ;) – egis Dec 26 '12 at 23:59

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.