Ubuntu – how can I configure a specific usb mouse model as left-handed

accessibilitymouse

I use a right-handed usb mouse in the office and a left-handed usb mouse at home on the same Ubuntu 11.04 laptop. How can I configure the one at home to be automatically set up to left-handed when plugged in?

Best Answer

Tutorial

Open up a terminal, and create a folder within your /etc/X11/ directory called xorg.conf.d and navigate to it:

sudo mkdir /etc/X11/xorg.conf.d
cd /etc/X11/xorg.conf.d/

Within this folder, make a file called 00-mouse-remap.conf, so bust open a text editor:

sudo gedit 00-mouse-remap.conf

The X Server should scan this directory for custom X11 scripts to load up at boot time. So the next step is to copy a config setting similar to this into the 00-mouse-remap.conf file you have just opened (customise to your will):

Section "InputClass"
    Identifier "Microsoft Bluetooth Mouse 5000 button remap"
    MatchProduct "Microsoft Bluetooth Notebook Mouse 5000"
    MatchIsPointer  "on"
    MatchDevicePath "/dev/input/event*"
    Driver          "evdev"
    Option          "SendCoreEvents" "true"
    Option          "Buttons" "8"
    Option          "ButtonMapping" "3 2 1 4 5 0 7 0"
EndSection

Since this is mapped for a specific product, you should have separate configurations for your left and right handed mice. :P

You can find the name of your device by entering in to terminal:

xinput list

You will then need to edit a gnome configuration entry, so run (in terminal or type it into a run session using ALT+F2):

gconf-editor

(In case you have upgraded to a version that uses dconf, that is, 11.10 and everything later, run dconf-editor instead)

And navigate to this entry, and uncheck the box next to the entry that says active:

apps > gnome_settings_daemon > plugins > mouse

(In case of dconf, is org > gnome > settings_daemon > plugins > mouse)

Just be aware, that this disables the Gnome mouse pointer settings for when you modify your pointer settings within the GUI. So if you want to use the Mouse Settings GUI, you'll have to reactivate this - although, it could take over your new lefty settings. ^^


Examples

For example, my xinput list is:

⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Acer T230H                                id=8    [slave  pointer  (2)]
⎜   ↳ Logitech USB Gaming Mouse                 id=9    [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Power Button                              id=7    [slave  keyboard (3)]
    ↳ Apple, Inc Apple Keyboard                 id=10   [slave  keyboard (3)]
    ↳ Apple, Inc Apple Keyboard                 id=11   [slave  keyboard (3)]

So I would configure my 00-mouse-remap.conf to look like so:

Section "InputClass"
    Identifier "Logitech USB Gaming Mouse button remap"
    MatchProduct "Logitech USB Gaming Mouse"
    MatchIsPointer  "on"
    MatchDevicePath "/dev/input/event*"
    Driver          "evdev"
    Option          "SendCoreEvents" "true"
    Option          "Buttons" "8"
    Option          "ButtonMapping" "3 2 1 4 5 0 7 0"
EndSection

References:

Ubuntu Forums Post by walkeraj