nixy/zremap: add udev triggered service

This commit is contained in:
Asmir A 2024-05-10 23:50:54 +02:00
parent d1da1f149b
commit 0e58c0a65f
Signed by: asmir
GPG Key ID: 020C42B7A9ABA3E2

View File

@ -174,24 +174,18 @@
# List services that you want to enable:
systemd = {
services = {
"zremap" = {
description = "Intercepts keyboard udev events";
wants = ["systemd-udevd.service"];
wantedBy = ["multi-user.target"];
"zremap@" = {
enable = true;
restartIfChanged = true;
serviceConfig.Nice = -20;
script = ''
sleep 1
KBD1="/dev/input/by-path/platform-i8042-serio-0-event-kbd"
KBD2="/dev/input/by-path/pci-0000:07:00.3-usbv2-0:1.1.3.2:1.1-event-kbd"
if [ -L "$KBD1" ]; then
${zremap.defaultPackage.${system}}/bin/zremap "$KBD1" &
fi
if [ -L "$KBD2" ]; then
${zremap.defaultPackage.${system}}/bin/zremap "$KBD2" &
fi
wait
'';
unitConfig = {
Description = "zremap on %I";
ConditionPathExists = "%I";
};
serviceConfig = {
Type = "simple";
ExecStart = "${zremap.defaultPackage.${system}}/bin/zremap %I";
};
};
};
@ -243,6 +237,9 @@
#Arduino UNO r4
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", MODE:="0666"
#zremap on new keyboard
ACTION=="add", SUBSYSTEM=="input", ATTRS{phys}!="", KERNEL=="event[0-9]*", ENV{ID_INPUT_KEY}=="1", ENV{ID_INPUT_KEYBOARD}=="1", TAG+="systemd", ENV{SYSTEMD_WANTS}+="zremap@$env{DEVNAME}.service"
'';
};