Super User is a question and answer site for computer enthusiasts and power users. 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 had the mouse buttons inverted on Gnome, and I wanted to do the same on xmonad but I don't know how to do it. Does anyone knows what is the adequate configuration?

share|improve this question

migrated from stackoverflow.com Jul 12 '11 at 1:05

This question came from our site for professional and enthusiast programmers.

    
I asked this in the irc and was told it was X server configuration.Am still to figure it out though. – Software Mechanic Jul 21 '11 at 13:52
up vote 3 down vote accepted

You can change mouse settings in xorg.conf (if you have one) or by using xmodmap. For 3-button mouse xmodmap command should look like:

xmodmap -e "pointer = 3 2 1"
(first button acts like third, second as second and third like first)

If you have more buttons you may list actual config using:

xmodmap -pp
share|improve this answer

You can configure that globally for X. Edit /etc/X11/xorg.conf, find the InputDevice section for your mouse, that should begin with something like

Section "InputDevice"
        Identifier  "Mouse2"
        Driver      "mouse"
        Option      "Device" "/dev/input/mouse1"

(...)

and add

       Option   "ButtonMapping" "3 2 1 4 5"

somewhere within that section. The numbers in the second quote correspond to the buttons you have, so if you have only 3 button mouse, you'd only need to put

       Option   "ButtonMapping" "3 2 1"

an so on.

After that, of course, restart your X.

EDIT: Another way would be to add something like xmodmap -e "pointer = 3 2 1" to your ~/.xinitrc file (if you use startx) or at the end of /etc/X11/Sessions/Xsession or /etc/X11/gdm/Xsession.

share|improve this answer

Here's a mouse-toggle-hand script:

#!/bin/sh
(xmodmap -pp | grep -q "\b1\b  *\b1\b") \
    && xmodmap -e "pointer = 3 2 1" \
    || xmodmap -e "pointer = 1 2 3"

It depends upon the output of xmodmap -pp looking much like this:

There are 10 pointer buttons defined.

    Physical        Button
     Button          Code
        1              3
        2              2
        3              1
        4              4
        5              5
        6              6
        7              7
        8              8
        9              9
       10             10

That may or may not be reliable/portable, so YMMV.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .