Keyboard input remapping for Linux/Wayland 
I have an usb keyboard with missing keys (|,< and >).

For X remapping was done by xmodmap

| is remapped to right AltGr + Y
< is remapped to right AltGr + ;
> is remapped to right AltGr + :

.Xmodmap
keycode  52 = y Y y Y bar U203A guillemotright
keycode 59 = comma semicolon comma semicolon less multiply periodcentered
keycode 60 = period colon period colon greater division U2026
But under wayland i had to change to evremap (https://github.com/wez/evremap)

To automatically activate remapping by a systemd service i did following

discover usb keyboard

#> dmesg
[ 4920.421719] usb 3-4.2: new low-speed USB device number 17 using xhci_hcd
[ 4920.539376] usb 3-4.2: New USB device found, idVendor=0e8f, idProduct=0022, bcdDevice= 2.10
[ 4920.539386] usb 3-4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 4920.539390] usb 3-4.2: Product: USB KB V11
[ 4920.539392] usb 3-4.2: Manufacturer: GASIA
[ 4920.614311] input: GASIA USB KB V11 as /devices/pci0000:00/0000:00:08.1/0000:03:00.4/usb3/3-4/3-4.2/3-4.2:1.0/0003:0E8F:0022.001A/input/input57
Search for name attribute

#> udevadm info -a -p /devices/pci0000:00/0000:00:08.1/0000:03:00.4/usb3/3-4/3-4.2/3-4.2:1.0/0003:0E8F:0022.001A/input/input57
ATTR{name}=="GASIA USB KB V11"
and build an udev rule for systemd tagging

/etc/udev/rules.d/10-local.rules
ACTION!="remove", SUBSYSTEMS=="input", ATTRS{name}=="GASIA USB KB V11", TAG+="systemd"
and reload udev and trigger

#> udevadm control --reload-rules
#> udevadm trigger --attr-match=subsystem=input

and search for a systemd device name with

#> systemctl list-units --type device --no-pager -a | grep V11
  dev-input-by\x2did-usb\x2dGASIA_USB_KB_V11\x2devent\x2dkbd.device                                                                               loaded active plugged USB_KB_V11
dev-input-by\x2dpath-pci\x2d0000:03:00.4\x2dusb\x2d0:4.2:1.0\x2devent\x2dkbd.device loaded active plugged USB_KB_V11
dev-input-event12.device loaded active plugged USB_KB_V11
sys-devices-pci0000:00-0000:00:08.1-0000:03:00.4-usb3-3\x2d4-3\x2d4.2-3\x2d4.2:1.0-0003:0E8F:0022.001A-input-input57-event12.device loaded active plugged USB_KB_V11
sys-devices-pci0000:00-0000:00:08.1-0000:03:00.4-usb3-3\x2d4-3\x2d4.2-3\x2d4.2:1.0-0003:0E8F:0022.001A-input-input57.device loaded active plugged USB_KB_V11
and check for status with

#> systemctl status "dev-input-by\x2did-usb\x2dGASIA_USB_KB_V11\x2devent\x2dkbd.device"
● dev-input-by\x2did-usb\x2dGASIA_USB_KB_V11\x2devent\x2dkbd.device - USB_KB_V11
Follows: unit currently follows state of sys-devices-pci0000:00-0000:00:08.1-0000:03:00.4-usb3-3\x2d4-3\x2d4.2-3\x2d4.2:1.0-0003:0E8F:0022.001A-input-input57-event12.device
Loaded: loaded
Active: active (plugged) since Mon 2023-09-25 09:32:57 CEST; 1h 27min ago
Until: Mon 2023-09-25 09:32:57 CEST; 1h 27min ago
Device: /sys/devices/pci0000:00/0000:00:08.1/0000:03:00.4/usb3/3-4/3-4.2/3-4.2:1.0/0003:0E8F:0022.001A/input/input57/event12
and install evremap with correct permission and ownership

#> ls -la /usr/bin/evremap
-rwxr-xr-x 1 root root 15726808 Sep 20 15:37 /usr/bin/evremap
and discover the name with

#> sudo evremap list-devices

and build the remapfile (using evtest to discover keycodes)

/etc/evremap.toml
device_name = "GASIA USB KB V11"

[[remap]]
input = ["KEY_RIGHTALT", "KEY_Z"]
output = ["KEY_RIGHTALT", "KEY_102ND"]

[[remap]]
input = ["KEY_RIGHTALT", "KEY_COMMA"]
output = ["KEY_102ND"]

[[remap]]
input = ["KEY_RIGHTALT", "KEY_DOT"]
output = ["KEY_LEFTSHIFT", "KEY_102ND"]
/etc/systemd/system/evremap.service
[Unit]
Description=Keyboard Remap
BindsTo=dev-input-by\x2did-usb\x2dGASIA_USB_KB_V11\x2devent\x2dkbd.device

[Service]
WorkingDirectory=/
ExecStart=/usr/bin/evremap remap /etc/evremap.toml -d 0
Restart=always

[Install]
WantedBy=dev-input-by\x2did-usb\x2dGASIA_USB_KB_V11\x2devent\x2dkbd.device
#> systemd enable evremap

[ view entry ] ( 1149 views )   |  print article

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next> Last>>