Quick, dirty and cheap way to get a left-handed mouse on Linux (tested on Ubuntu only).
Just place this function in your ~/.bash_aliases
file:
# Left-handed mouse buttons
function left_hand_mouse () {
xinput list | grep -e "id\=.*slave\s*pointer" | while read -r LINE ; do
DEVICE_NAME=$(echo "$LINE" | cut -f 1)
DEVICE_ID=$(echo "$LINE" | cut -f 2 | cut -d= -f 2)
echo -e "Switching mouse button for $DEVICE_NAME\tDEVICE ID = $DEVICE_ID"
xinput set-button-map $DEVICE_ID 3 2 1
done
}
Don't forget to source the changes:
$ . ~/.bashrc
To switch the mouse button positions to left-handed, call the function from the terminal:
$ left_hand_mouse
My script is very old--there was no Wayland back then. I also stopped using it once companies started manufacturing high quality left-handed mice, such as this one.