3

Is there a way to swap click and middle click buttons permanently in Kubuntu?

    $xinput list 
    Virtual core pointer                        id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ ImExPS/2 Generic Explorer Mouse           id=10   [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)]
    ↳ cx88 IR (Leadtek Winfast 2000XP           id=8    [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=9    [slave  keyboard (3)]
  • Please append the output of xinput list to your question. – Helio May 26 '15 at 14:43
1

Getting the ID of your mouse:

You can get it running xinput list:

⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ HID 046a:0023                             id=9    [slave  pointer  (2)]
⎜   ↳ Logitech G9x Laser Mouse                  id=10   [slave  pointer  (2)]
⎜   ↳ Logitech G9x Laser Mouse                  id=11   [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)]
    ↳ HID 046a:0023                             id=8    [slave  keyboard (3)]

I have two mouse IDs (10 and 11), therefore I have to test the right ID.


Swapping the buttons:

You can swap the mouse buttons running this (where 10 is the ID):

xinput set-button-map 10 2 1 3

You can revert the change with:

xinput set-button-map 10 1 2 3

Swap the buttons automatically when X starts:

  • Run this command to edit the 91swapmousebuttons file:

    sudo nano /etc/X11/Xsession.d/91swapmousebuttons
    
  • Add this line to it:

    xinput set-button-map 10 2 1 3
    

Explaination of the parameters passed to xinput:

  • set-button-map changes the button map of a device.
  • 10 is the device ID.
  • 2 1 3 means:
    • 2: It's on the 1st position, so the first button (LMB) is mapped to button 2 (MMB).
    • 1: It's on the 2nd position, so the second button (MMB) is mapped to button 1 (LMB).
    • 1: It's on the 3rd position, so the third button (RMB) is mapped to button 3 (LMB).

Note that LMB is Left Mouse Button, MMB is Mid Mouse Button and so on.

Quote from man xinput:

Change the button mapping of device. The buttons are specified in physical order (starting with button 1) and are mapped to the logical button provided. 0 disables a button. The default button mapping for a device is 1 2 3 4 5 6 etc.

  • @Helio Nice phrasing :) "Aggresively improved formatting" thanks for the improvement :) – A.B. May 26 '15 at 19:48
  • No offence, but I very much doubt that xinput command will work from Xsession.d. Did you test it? But a great answer anyway. – Pilot6 May 26 '15 at 20:25
  • @Helio Did you test that 'Xsession.d' script? – Pilot6 May 26 '15 at 20:53
  • @Pilot6 I didn't. – Helio May 26 '15 at 21:20
  • I did and it does not. I would suggest to move it to /etc/xdg/autostart. But .desktop file is needed there. – Pilot6 May 26 '15 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.