I'm left-handed, so I have my primary mouse button set to the right button. This works fine on my touchpad buttons, and it used to work fine on my external Bluetooth mouse as well. But now suddenly, each time I connect the external mouse, the primary button on the mouse is the left one, while the touchpad primary button is still the right one. I can solve this by going to Settings > Mouse & Touchpad > Primary Button and set it to Left and then to Right. Of course, I'd rather not have to do this each time the mouse reconnects. Any suggestions?

  • Are you comfortable with the command line?
    – waltinator
    Oct 13, 2020 at 15:38
  • Yes definitely, I use the command line to Bluetooth-connect to the mouse anyways. I was indeed thinking that maybe I could run a command periodically or something, but I wouldn't know what command
    – flipjacob
    Oct 14, 2020 at 8:47

3 Answers 3


I use a KVM switcher box and so I have the same issue every time I switch since upgrading.

At the moment I have this quick and dirty script. Run it in a terminal as the logged in user;

xinput list | grep Mouse | sed -nre 's/^.*\sid=([0-9]+)\s.*$/\1/p' | xargs -r -I '{}' echo xinput set-button-map {} 3 2 1

Hope to get something better but should be useful for now.

For completeness, it's worth noting that you can also use the mouse settings UI tool, and change the primary button to right handed and then back to left handed.


I now have a more convenient solution that is automated for each kvm switch, but it's still a hacky/dirty solution, and I run a script after login...

Customise the following for your vendor id and product id, based on output of lsusb. Where the hex number with a colon in the middle is the {idvendor}:{idproduct} for your mouse. Also, as flipjacob adds, customise "Mouse" string in the grep statement to your match what you get from xinput.

Create a file (as root) /etc/udev/rules.d/80-force-left-handed-mouse-on-plugin-event.rules with the following contents

ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0047", ACTION=="bind", RUN+="/root/notify-mouse-plugged.sh"

Create the script that it will run (as root) /root/notify-mouse-plugged.sh.


umask 0000
echo $ACTION >> /tmp/mouse-flag
date >> /tmp/mouse-flag

And finally create the script to pick up the 'notification' in the context of the logged in user. I run this after logging in in a terminal and leave it running there.

Listener script $HOME/listen-for-mouse-plugged.sh.


echo "" > /tmp/mouse-flag

tail -qfn 0 /tmp/mouse-flag 2>/dev/null | while read s
  #inotifywait -e create /tmp/mouse-flag
  echo reset mouse $s
  xinput list | grep Mouse | sed -nre 's/^.*\sid=([0-9]+)\s.*$/\1/p' | xargs -I '{}' xinput set-button-map {} 3 2 1

  #sleep 5

It fires the listener loop 3 times for me, but that is of little consequence for something I hope to throw away soon.

  • Thank you, that works! I didn't know that the id number is not fixed, so thank you for providing me with this script. I'd like to add that Mouse may need to be substituted for whatever name your mouse has in the xinput output, in my case it is RAPOO Rapoo 2.4G Wireless Device so I set the grep expression not to Mouse but to RAPOO.
    – flipjacob
    Nov 9, 2020 at 14:46

I had the same issue and after much searching, this worked for me: Open Startup Applications Preferences and Add the following command

xmodmap -e "pointer = 3 2 1"

This worked immediately and persists after a re-start, and persists when the bluetooth mouse re-awakens from inactivity.

Running 20.10 - hope this bug gets fixed soon.


Did someone opened an issue on Launchad?

There is only https://bugs.launchpad.net/ubuntu/+source/lxqt-config/+bug/1860918 as far as i know.


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.