summary refs log tree commit diff
path: root/nixos/modules/services/misc/logkeys.nix
blob: 0082db63a06ae754c97cf7527a7535b1308fb127 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.logkeys;
in {
  options.services.logkeys = {
    enable = mkEnableOption "logkeys service";

    device = mkOption {
      description = "Use the given device as keyboard input event device instead of /dev/input/eventX default.";
      default = null;
      type = types.nullOr types.str;
      example = "/dev/input/event15";
    };
  };

  config = mkIf cfg.enable {
    systemd.services.logkeys = {
      description = "LogKeys Keylogger Daemon";
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        ExecStart = "${pkgs.logkeys}/bin/logkeys -s${lib.optionalString (cfg.device != null) " -d ${cfg.device}"}";
        ExecStop = "${pkgs.logkeys}/bin/logkeys -k";
        Type = "forking";
      };
    };
  };
}