at 24.11-pre 815 B view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.logkeys; 7in { 8 options.services.logkeys = { 9 enable = mkEnableOption "logkeys, a keylogger service"; 10 11 device = mkOption { 12 description = "Use the given device as keyboard input event device instead of /dev/input/eventX default."; 13 default = null; 14 type = types.nullOr types.str; 15 example = "/dev/input/event15"; 16 }; 17 }; 18 19 config = mkIf cfg.enable { 20 systemd.services.logkeys = { 21 description = "LogKeys Keylogger Daemon"; 22 wantedBy = [ "multi-user.target" ]; 23 serviceConfig = { 24 ExecStart = "${pkgs.logkeys}/bin/logkeys -s${lib.optionalString (cfg.device != null) " -d ${cfg.device}"}"; 25 ExecStop = "${pkgs.logkeys}/bin/logkeys -k"; 26 Type = "forking"; 27 }; 28 }; 29 }; 30}