summaryrefslogtreecommitdiff
path: root/modules/services/kwm/default.nix
blob: 5fb6c5635c310effe988884d371ac4262b132941 (plain)
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
50
51
52
53
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.kwm;
in

{
  options = {
    services.kwm.enable = mkOption {
      type = types.bool;
      default = false;
      description = "Whether to enable the khd window manager.";
    };

    services.kwm.package = mkOption {
      type = types.path;
      default = pkgs.kwm;
      defaultText = "pkgs.kwm";
      description = "This option specifies the kwm package to use.";
    };

    services.kwm.kwmConfig = mkOption {
      type = types.lines;
      default = "";
      example = ''kwmc rule owner="iTerm2" properties={role="AXDialog"}'';
      description = "Config to use for {file}`kwmrc`.";
    };
  };

  config = mkIf cfg.enable {

    security.accessibilityPrograms = [ "${cfg.package}/kwm" ];

    environment.systemPackages = [ cfg.package ];

    environment.etc."kwmrc".text = cfg.kwmConfig;

    launchd.user.agents.kwm = {
      serviceConfig.ProgramArguments = [ "${cfg.package}/kwm" ]
        ++ optionals (cfg.kwmConfig != "") [ "-c" "/etc/kwmrc" ];
      serviceConfig.KeepAlive = true;
      serviceConfig.ProcessType = "Interactive";
      serviceConfig.Sockets.Listeners =
        { SockServiceName = "3020";
          SockType = "dgram";
          SockFamily = "IPv4";
        };
    };

  };
}