3.0 KiB
+++ date = '2026-01-18T21:46:50-07:00' draft = false title = 'Keyboard' +++
Key-remapping and backlights
My new laptop Lenovo Slim came with an interesting feature on windows, the keyboard backlight would turn on and off automatically when typing. This is actually pretty cool, so I enabled it on my linux install. I also wanted to remap esc to capslock and keep the ctrl functionality. I was not able to find a way to do the remap in swaywm by itself. Since I had to install another utility, or 2, I decided that it should be able to do the remap at the console level so that it's available from first login and for all accounts. Utilities:
Keyd
Install with pacman
pacman -S keyd
configure at /etc/keyd/default.conf
[ids]
*
[main]
# Maps capslock to escape when pressed and control when held.
capslock = overload(control, esc)
Keyd grabs the input and creates a virtual interface. In order for keyboard-backlightd to work we're going to need a persistant named interface so we create a udev rule.
/etc/udev/rules.d/99-keyd.rules
SUBSYSTEM=="input", ATTRS{name}=="keyd virtual keyboard", SYMLINK+="input/by-id/keyd-keyboard"
Keyboard-backlightd
Install with aur
aur sync keyboard-backlightd
pacman -Sy keyboard-backlightd
configure at /etc/conf.d/keyboard-backlightd
# Inputs to monitor.
# Should be on form -i /dev/input/... -i /dev/input/...
#
# See README.md for more info
INPUTS=-i /dev/input/by-id/keyd-keyboard \
-i /dev/input/by-path/platform-AMDI0010:02-event-mouse \
-i /dev/input/by-path/platform-AMDI0010:03-event-mouse
# Path to LED under /sys to control
LED=/sys/class/leds/platform::kbd_backlight
# Default brightness
BRIGHTNESS=1
# Timeout in milliseconds after which to turn off the LED.
TIMEOUT=7000
# Time to wait for files showing up. This is useful during boot to handle
# device nodes not yet being available due to late kernel module loading.
WAIT=15000
# Extra command line flags to pass to keyboard-backlightd
# See --help for a full list (though some overlap with the other settings
# in this file). Of particular interest might be:
# * --no-adaptive-brightness
# * --verbose
FLAGS=
# Set service log level
RUST_LOG=warn
This monitors the virtual interface setup by the keyd udev rule, it also monitors for mouse inputs. We'll want to check with brightnessctl or another means the available brightness levels and adjust the config as necessary.
Enable services
Both of these utilities ship with systemd unit files so we just need to enable them.
systemctl enable --now keyd.service
systemctl enable --now keyboard-backlightd.service
In conclusion
These utilities work nicely together. keyd looks to be very powerful utility and using it to just to remap the capslock key seems a bit of a waste, I will be looking into it's potential more.