commit 98a0b5b07c5a64dae49da148468a28dee4a7502d
parent 06e319b00406ee89dbb27d7d4fa63fdf9be71cb0
Author: Leah (ctucx) <git@ctu.cx>
Date: Tue, 17 Oct 2023 09:19:07 +0200
parent 06e319b00406ee89dbb27d7d4fa63fdf9be71cb0
Author: Leah (ctucx) <git@ctu.cx>
Date: Tue, 17 Oct 2023 09:19:07 +0200
modules/darwin: add modified skhd module
2 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/modules/darwin/skhd.nix b/modules/darwin/skhd.nix @@ -0,0 +1,47 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.ctucx.skhd; +in + +{ + options = { + services.ctucx.skhd.enable = mkOption { + type = types.bool; + default = false; + description = lib.mdDoc "Whether to enable the skhd hotkey daemon."; + }; + + services.ctucx.skhd.package = mkOption { + type = types.package; + default = pkgs.skhd; + description = lib.mdDoc "This option specifies the skhd package to use."; + }; + + services.ctucx.skhd.skhdConfig = mkOption { + type = types.lines; + default = ""; + example = "alt + shift - r : chunkc quit"; + description = lib.mdDoc "Config to use for {file}`skhdrc`."; + }; + }; + + config = mkIf cfg.enable { + + environment.etc."skhdrc".text = cfg.skhdConfig; + + launchd.user.agents.skhd = { + path = [ config.environment.systemPath ]; + + serviceConfig.ProgramArguments = [ + "/bin/sh" "-c" + "/bin/wait4path /nix/store && exec ${cfg.package}/bin/skhd" + ] ++ optionals (cfg.skhdConfig != "") [ "-c" "/etc/skhdrc" ]; + serviceConfig.KeepAlive = true; + serviceConfig.ProcessType = "Interactive"; + }; + + }; +}
diff --git a/modules/default.nix b/modules/default.nix @@ -22,12 +22,14 @@ ./darwin/quirks.nix ./darwin/hidutil.nix ./darwin/syncthing.nix + ./darwin/skhd.nix ] else []) (if (currentSystem == "x86_64-darwin") then [ inputs.agenix.darwinModules.default ./darwin/quirks.nix ./darwin/hidutil.nix ./darwin/syncthing.nix + ./darwin/skhd.nix ] else []) ]);