Created
September 30, 2026 19:12
-
-
Save bootandy/6c87acedbdb6dfa5aed0b13f1944c145 to your computer and use it in GitHub Desktop.
Fix mouse script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # requires: sudo apt-get install inputplug | |
| # cp <this> to .config/kvm-hotplug.sh | |
| #!/bin/bash | |
| # inputplug triggers this script on input changes. | |
| # $1 = Event Type (e.g., XIDeviceEnabled), $2 = Device ID | |
| if [ "$1" = "XIDeviceEnabled" ]; then | |
| # Give Xorg a split second to finish registering the hardware | |
| sleep 0.5 | |
| # 1. FIX THE MOUSE BUTTONS | |
| # Dynamically find the mouse ID by matching 'Left' | |
| mouseid=$(xinput | grep -i "Left" | sed -n 's/.*id=\([0-9]*\).*/\1/p' | head -n 1) | |
| if [ -n "$mouseid" ]; then | |
| xinput set-button-map "$mouseid" 3 1 8 4 5 6 7 9 2 10 11 12 13 14 15 | |
| fi | |
| # 2. FORCE THE KEYBOARD OVERRIDES (Safety backup for the KVM) | |
| setxkbmap -option "caps:swapescape,ctrl:swap_lalt_lctl" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment