Mouse button mapping in Xorg.conf

I purchased a Logitech G400 mouse to temporarily replace my Logitech MX Anywhere mouse, which I forgot at home. I wanted to use the top button for pasting instead of the scroll wheel button, which I feel is too hard to press.

This command solves the problem, by swapping the functions of button 2 (the scrollwheel button) and 10 (the top button):

$ xmodmap -e "pointer = 1 10 3 4 5 6 7 8 9 2"

The trick is that I want it done automatically when I use the G400.

My Debian Wheezy installation didn’t have a xorg.conf file, but there is nowadays an option to put specific conf snippets in /etc/X11/xorg.conf.d/*.conf:

$ mkdir /etc/X11/xorg.conf.d
$ vi /etc/X11/xorg.conf.d/LogitechG400.conf

There are a few directives in the InputClass section that can match device attributes. I used MatchProduct and MatchIsPointer (to be safe). You can just as well use MatchUSBID, I guess. These are the contents of my /etc/X11/xorg.conf-d/LogitechG400.conf file:

Section "InputClass"
Identifier "evdev mouse"
MatchProduct "Logitech Gaming Mouse G400"
MatchIsPointer "true"
Option "ButtonMapping" "1 10 3 4 5 6 7 8 9 2"
EndSection

The ButtonMapping option swaps the function of button 2 (the scrollwheel button) and 10 (the top button).

Now I can paste using the top button with the G400 mouse.

 

One thought on “Mouse button mapping in Xorg.conf”

  1. In my case the Xorg’s logfile show that the buttonmapping is done *before* Xorg’s autoconfiguration reversing the buttonmapping to default.

    37.553] (**) Option “ButtonMapping” “1 2 3 5 4”
    [ 37.553] (**) Option “Emulate3Buttons” “false”
    [ 37.553] (**) sysmouse: ZAxisMapping: buttons 4 and 5
    [ 37.553] (**) sysmouse: Buttons: 5

    i.e swapping buttons 4 and 5 does not work ….

Leave a Reply

Your email address will not be published. Required fields are marked *