summary refs log tree commit diff
path: root/nixos/modules/services/hardware/pommed.nix
blob: 32599554fc12c6c16b58b9cb36827f9cfa280275 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ config, pkgs, ... }:

with pkgs.lib;

{

  options.services.hardware.pommed = {
    enable = mkOption {
      default = false;
       description = ''
        Whether to use the pommed tool to handle Apple laptop keyboard hotkeys.
      '';
    };

    configFile = mkOption {
      default = "${pkgs.pommed}/etc/pommed.conf";
      description = ''
        The contents of the pommed.conf file.
      '';
    };
  };

  config = mkIf config.services.hardware.pommed.enable {
    environment.systemPackages = [ pkgs.polkit ];

    environment.etc = [
      { source = config.services.hardware.pommed.configFile;
        target = "pommed.conf";
      }
    ];

    services.dbus.packages = [ pkgs.pommed ];

    jobs.pommed = { name = "pommed";

      description = "Pommed hotkey management";

      startOn = "started dbus";

      postStop = "rm -f /var/run/pommed.pid";

      exec = "${pkgs.pommed}/bin/pommed";

      daemonType = "fork";

      path = [ pkgs.eject ];
    };
  };
}