diff --git a/default.nix b/default.nix index 2007a8e..7d00f2e 100644 --- a/default.nix +++ b/default.nix @@ -56,6 +56,7 @@ let ./modules/services/ofborg ./modules/services/postgresql ./modules/services/redis + ./modules/services/skhd ./modules/programs/bash ./modules/programs/fish.nix ./modules/programs/man.nix diff --git a/modules/services/skhd/default.nix b/modules/services/skhd/default.nix new file mode 100644 index 0000000..093fdd3 --- /dev/null +++ b/modules/services/skhd/default.nix @@ -0,0 +1,47 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.skhd; + +in { + + options = { + services.skhd.enable = mkOption { + type = types.bool; + default = false; + description = "Whether to enable the skhd hotkey daemon."; + }; + + services.skhd.package = mkOption { + type = types.package; + example = literalExample "pkgs.skhd"; + description = "This option specifies the skhd package to use."; + }; + + services.skhd.skhdConfig = mkOption { + type = types.lines; + default = ""; + example = "alt + shift - r : chunkc quit"; + description = "Config to use for skhdrc."; + }; + }; + + config = mkIf cfg.enable { + + environment.etc."skhdrc".text = cfg.skhdConfig; + + launchd.user.agents.skhd = { + path = [ cfg.package config.environment.systemPath ]; + + serviceConfig.ProgramArguments = [ "${cfg.package}/bin/skhd" ] + ++ optionals (cfg.skhdConfig != "") [ "-c" "/etc/skhdrc" ]; + serviceConfig.KeepAlive = true; + serviceConfig.ProcessType = "Interactive"; + serviceConfig.StandardOutPath = "/tmp/skhd.out"; + serviceConfig.StandardErrorPath = "/tmp/skhd.err"; + }; + + }; +}