1{ config, lib, pkgs, ... }:
2
3with lib;
4
5{
6
7 options = {
8
9 services.hardware.pommed = {
10
11 enable = mkOption {
12 type = types.bool;
13 default = false;
14 description = ''
15 Whether to use the pommed tool to handle Apple laptop keyboard hotkeys.
16 '';
17 };
18
19 configFile = mkOption {
20 type = types.path;
21 description = ''
22 The path to the <filename>pommed.conf</filename> file.
23 '';
24 };
25 };
26
27 };
28
29 config = mkIf config.services.hardware.pommed.enable {
30 environment.systemPackages = [ pkgs.polkit ];
31
32 environment.etc."pommed.conf".source = config.services.hardware.pommed.configFile;
33
34 services.hardware.pommed.configFile = "${pkgs.pommed}/etc/pommed.conf";
35
36 services.dbus.packages = [ pkgs.pommed ];
37
38 systemd.services.pommed = {
39 description = "Pommed hotkey management";
40 wantedBy = [ "multi-user.target" ];
41 after = [ "dbus.service" ];
42 postStop = "rm -f /var/run/pommed.pid";
43 script = "${pkgs.pommed}/bin/pommed";
44 serviceConfig.Type = "forking";
45 path = [ pkgs.eject ];
46 };
47 };
48}