Skip to content

Instantly share code, notes, and snippets.

@jayv
Last active June 16, 2022 06:32
Show Gist options
  • Save jayv/46af012f2e041c2fa04c27e000f4b318 to your computer and use it in GitHub Desktop.
Save jayv/46af012f2e041c2fa04c27e000f4b318 to your computer and use it in GitHub Desktop.
Remap Alt and Windows key in Linux at the driver via udev hwdb
$ sudo vi /etc/udev/hwdb.d/70-keyboard.hwdb
# evdev:input:b<bus_id>v<vendor_id>p<product_id>e<version_id>-<modalias>
# use `lsusb` and `sudo udevadm info /dev/input/by-id/usb-*` to get values for bus, vendor, product, revision
# use `sudo evtest` to get scan code for lhs to rhs key mapping from /usr/include/linux/input.h
# Metadot Das Keyboard Pro 4 (MAC)
evdev:input:b0003v24F0*
KEYBOARD_KEY_700e2=leftmeta
KEYBOARD_KEY_700e3=leftalt
$ sudo systemd-hwdb update
$ sudo udevadm trigger
# debug
$ sudo udevadm --debug test-builtin keyboard /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1/0003:1B1C:1B36.001B/input/input95/event24
# to get the input device path, unplug/plug keyboard find the matching vendor, product id while running
$ sudo udevadm monitor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment