Skip to content

Instantly share code, notes, and snippets.

@sirf
Last active April 2, 2024 14:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirf/2a901aeddab3aa6f035d35d514f19fbd to your computer and use it in GitHub Desktop.
Save sirf/2a901aeddab3aa6f035d35d514f19fbd to your computer and use it in GitHub Desktop.
How to disable a specific mouse button with udev rules
evdev:name:Kingsis Peripherals Evoluent VerticalMouse*
KEYBOARD_KEY_90004=reserved

How to disable a specific mouse button with udev rules

Execute sudo evtest

No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:	Lid Switch
/dev/input/event1:	Power Button
/dev/input/event2:	Sleep Button
/dev/input/event3:	Power Button
/dev/input/event4:	AT Translated Set 2 keyboard
/dev/input/event5:	Video Bus
/dev/input/event21:	Kingsis Peripherals Evoluent VerticalMouse 4
Select the device event number [0-27]: 21

Select your device from the list, then click the mouse button you wish to disable and observe the output:

Event: time 1712048987.316403, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90004
Event: time 1712048987.316403, type 1 (EV_KEY), code 275 (BTN_SIDE), value 1
Event: time 1712048987.316403, -------------- SYN_REPORT ------------
Event: time 1712048987.482414, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90004
Event: time 1712048987.482414, type 1 (EV_KEY), code 275 (BTN_SIDE), value 0

Note the device name (trailing wildcards can be used) and the MSC_SCAN value, then add a rule to /etc/udev/hwdb.d/61-evdev-local.hwdb

Execute sudo systemd-hwdb update, and finally unplug the device and then plug it back in again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment