Skip to content

Latest commit

 

History

History
65 lines (54 loc) · 1.69 KB

README.md

File metadata and controls

65 lines (54 loc) · 1.69 KB

caps-esc

Tiny background utility for mapping Esc key to CapsLock key. Just like xcape but for X11 and Wayland.

Usage

caps-esc /dev/input/event<x>

where x corresponds to the keyboard device event input.

Building and installation

sudo dnf install -y libevdev-devel
cd caps-esc
zig build -Drelease
sudo install -s ./zig-out/bin/caps-esc /usr/local/bin

Create systemd unit file /etc/systemd/system/[email protected]

[Unit]
Description=Remap Esc key to CapsLock
#BindsTo=sys-devices-virtual-input-%i.device
#After=sys-devices-virtual-input-%i.device
StopWhenUnneeded=true

[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/caps-esc /dev/input/%i

Create udev rules /etc/udev/rules.d/99-caps-esc.rules

ACTION=="add", KERNEL=="event*", SUBSYSTEM=="input", ENV{ID_INPUT_KEYBOARD}=="1", \
ENV{DEVPATH}!="/devices/virtual/input/*", ENV{SYSTEMD_ALIAS}+="/sys/devices/virtual/input/%k", \
OWNER="root", TAG+="systemd", ENV{SYSTEMD_WANTS}="caps-esc@$kernel.service"

Initialize and run

$ sudo systemctl daemon-reload 
$ sudo udevadm control --reload
$ sudo udevadm trigger --action=add

Check the status

$ systemctl status caps-esc@\*.service

Getting some device information

lsusb
udevadm info -a -n /dev/input/event<x>

References

Credits

Inspired by osm and xcape