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?– waltinatorOct 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– flipjacobOct 14, 2020 at 8:47
3 Answers
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.
UPDATE/EDIT BELOW
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
.
#!/bin/bash
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
.
#!/bin/bash
echo "" > /tmp/mouse-flag
tail -qfn 0 /tmp/mouse-flag 2>/dev/null | while read s
do
#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
done
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 thatMouse
may need to be substituted for whatever name your mouse has in thexinput
output, in my case it isRAPOO Rapoo 2.4G Wireless Device
so I set thegrep
expression not toMouse
but toRAPOO
. 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.
Thanks.