diff --git a/nixy/configuration.nix b/nixy/configuration.nix index 49eb326..8f5352f 100644 --- a/nixy/configuration.nix +++ b/nixy/configuration.nix @@ -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" ''; };