Skip to content

Instantly share code, notes, and snippets.

@desaster
Last active August 27, 2023 21:04
Show Gist options
  • Save desaster/c3f8b081016fcdf2a3f7196b422a118f to your computer and use it in GitHub Desktop.
Save desaster/c3f8b081016fcdf2a3f7196b422a118f to your computer and use it in GitHub Desktop.
remapping capslock to ctrl at low level in Linux

do the following in console, not X11

Prepare

# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event4:      AT Translated Set 2 keyboard
# evtest /dev/input/event4                                                                            

Input driver version is 1.0.1                                                                                                            
Input device ID: bus 0x11 vendor 0x1 product 0x1 version 0xab41                                                                          

Event: time 1630747582.938161, type 4 (EV_MSC), code 4 (MSC_SCAN), value 3a
Event: time 1630747582.938161, type 1 (EV_KEY), code 58 (KEY_CAPSLOCK), value 0

Setup

/lib/udev/hwdb.d/90-keyboard-changes.hwdb:

evdev:input:b0011v0001p0001*
  KEYBOARD_KEY_3a=leftctrl
# systemd-hwdb -s update
# udevadm trigger /dev/input/event4

Test

# evtest /dev/input/event4

Event: time 1630751006.715770, type 4 (EV_MSC), code 4 (MSC_SCAN), value 3a
Event: time 1630751006.715770, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment