How do I swap mouse buttons to be left handed from the terminal?

xmodmap -e "pointer = 3 2 1"

in a terminal should work. If you want to run that command at the start of lightdm (the default login screen), you can edit /etc/lightdm/lightdm.conf like described here - use the xmodmap command instead of xbacklight in the script, of course.


You can use also xinput to do this.

It will switch the buttons on one mouse only.

First use-

xinput list

To see where you mouse is will be somthing like

"USB Mouse"     id=12       [slave pointer]

So use the id number for the next command to switch the button assignment.

xinput set-button-map 12 3 2 1

So, you would switch out 12 with the id number of your mouse.

Source: 1


xmodmap is the command to change the mouse button mapping:

xmodmap -e "pointer = 3 2 1"

will remap the first three buttoons, left, middle and right, to act like , right, middle and left - not actually changing the middle button mapping.

That applies the change to the current session - more precisely, to the current X display, for exanple :0.

To save the change persistent over sessions, put the mapping into the file

~/.Xmodmap

If it does not exist, create it, liketouch ~/.Xmodmap

Edit it to add the line

pointer = 3 2 1

If there already is a pointer line, it may have some function, of course; Instead of replacing it, better modify the first three values - keeping a comment with the old:

For example,

pointer = 1 2 3 4 5 16 17 8 9 10 11 12 13 14 15 6 7 18 19 20 21 22 23 24

becomes

!pointer = 1 2 3 4 5 16 17 8 9 10 11 12 13 14 15 6 7 18 19 20 21 22 23 24
pointer = 3 2 1 4 5 16 17 8 9 10 11 12 13 14 15 6 7 18 19 20 21 22 23 24


I'm used to ~/.Xmodmap allways just working; But see .Xmodmap works only when automatic login disabled? if it does not.