Switching side buttons on Linux Mint
I have a Razer mouse. Linux Mint seems to switch the side buttons' actions, where the button that I feel means "forward" does "back," and vice versa. I wrote a startup script to solve this problem by flipping them around.
To start, I used xev
to figure out which my side buttons were. I found that they were 8 and 9.
Next, I used xinput to figure out the buttons currently set up:
12 | $ xinput | grep -i "usb optical mouse" | sed -e "s/.*id=\(\S*\)\s*.*/\1/"
8
|
So the USB optical mouse is ID 8. Next, check the button map:
12 | $ xinput get-button-map 8
1 2 3 4 5 6 7 8 9 10 11 12 13
|
Finally, to switch them:
1 | xinput set-button-map 8 1 2 3 4 5 6 7 9 8 10 11 12 13
|
And it worked! Then I added the code to my ~/.profile
:
123456789 | MOUSE_SW_BTNS_ID=`xinput | grep -i "usb optical mouse" | sed -e "s/.*id=\(\S*\)\s*.*/\1/"`
if [ ! -z "$MOUSE_SW_BTNS_ID" ]; then
MOUSE_SW_BTNS_MAP=`xinput get-button-map $MOUSE_SW_BTNS_ID`
MOUSE_SW_BTNS_CMP="1 2 3 4 5 6 7 8 9 10 11 12 13 "
if [ "$MOUSE_SW_BTNS_MAP" = "$MOUSE_SW_BTNS_CMP" ]; then
MOUSE_SW_BTNS_SET="1 2 3 4 5 6 7 9 8 10 11 12 13"
xinput set-button-map $MOUSE_SW_BTNS_ID $MOUSE_SW_BTNS_SET
fi
fi
|
Ches Koblents
January 16, 2019