Input Remap Utils at the Arch Wiki
envremap sounds great!
You can usually find input devices by name here:
$ ls -l /dev/input/by-id/
total 0
lrwxrwxrwx 1 root root 9 Mar 7 13:55 usb-13ba_Barcode_Reader-event-if01-> ../event8
lrwxrwxrwx 1 root root 9 Mar 7 13:55 usb-13ba_Barcode_Reader-event-kbd-> ../event5
lrwxrwxrwx 1 root root 9 Mar 7 13:55 usb-13ba_Barcode_Reader-if01-event-mouse -> ../event6
lrwxrwxrwx 1 root root 9 Mar 7 13:55 usb-13ba_Barcode_Reader-if01-mouse -> ../mouse1
lrwxrwxrwx 1 root root 9 Mar 7 13:55 usb-PixArt_USB_Optical_Mouse-event-mouse -> ../event4
lrwxrwxrwx 1 root root 9 Mar 7 13:55 usb-PixArt_USB_Optical_Mouse-mouse -> ../mouse0
As you can see the kbd
, or keyboard
is at /dev/input/event5
based on the above output. But what is it called?! Lets look at
/proc/bus/input/devices
$ cat /proc/bus/input/devices | grep -A3 -B5 event5
I: Bus=0003 Vendor=13ba Product=0018 Version=0110
N: Name="Barcode Reader "
P: Phys=usb-0000:00:14.0-1.4/input0
. . .
I have a weird setup, admittedly. My keyboard is labeled "Barcode Reader " since I use a dongle to conver my keyboard's PS/2 output to USB.
Yes, this dongle has this keyboard device named with a trailing space!
This isn't as obvious when you look at the recommended output of
envremap
! (unless you put a |cat -A
at the end of the command)
$ sudo evremap list-devices
. . .
$ sudo evremap list-devices
Name: AT Translated Set 2 keyboard
Path: /dev/input/event3
Phys: isa0060/serio0/input0
Name: Barcode Reader
Path: /dev/input/event5
Phys: usb-0000:00:14.0-1.4/input0
. . .
I copied the systemd unit file from /usr/lib/systemd/system/
to
/etc/systemd/system/
and named them with easy to remember filenames.
sudo cp /usr/lib/systemd/system/envremap.service ps2-dell-keyboard\@envremap.service
sudo cp /usr/lib/systemd/system/envremap.service laptop-keyboard\@envremap.service
$ cat << EOF > /etc/laptop-keyboard.toml
device_name = "AT Translated Set 2 keyboard"
#phys = "usb-0000:00:14.0-1/input0"
[[remap]]
input = ["KEY_CAPSLOCK"]
output = ["KEY_ESC"]
EOF
$ cat << EOF > /etc/ps2-dell-keyboard.toml
device_name = "Barcode Reader "
#phys = "usb-0000:00:14.0-1/input0"
[[remap]]
input = ["KEY_CAPSLOCK"]
output = ["KEY_ESC"]
EOF
The following command just lists the toml lines in the unit config.
$ find /etc/systemd/system/ -type f -name "*envremap*" -exec echo "{}"
\; -exec grep toml "{}" \;
/etc/systemd/system/ps2-dell-keyboard@envremap.service
ExecStart=bash -c "/usr/bin/evremap remap /etc/ps2-dell-keyboard.toml
-d 0"
/etc/systemd/system/laptop-keyboard@envremap.service
ExecStart=bash -c "/usr/bin/evremap remap /etc/laptop-keyboard.toml -d 0"
$ sudo systemctl enable laptop-keyboard\@envremap.service
$ sudo systemctl start laptop-keyboard\@envremap.service
$ sudo systemctl enable ps2-dell-keyboard\@envremap.service
$ sudo systemctl start ps2-dell-keyboard\@envremap.service
Of course, envremap
's touted feature might also be of use to you:
Remap the
CAPSLOCK
key so that it producesCTRL
when held, butESC
if tapped
If that's the case, follow the instructions on the project repo when
creating your .toml
config file.