Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services/skhd: cleanup and add errorLogFile/outLogFile #1232

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 43 additions & 18 deletions modules/services/skhd/default.nix
Original file line number Diff line number Diff line change
@@ -1,46 +1,71 @@
{ config, lib, pkgs, ... }:

with lib;

{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.skhd;
in

inherit (lib) mkOption types;
in
{
options = {
services.skhd.enable = mkOption {
options.services.skhd = {
enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable the skhd hotkey daemon.";
};

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

services.skhd.skhdConfig = mkOption {
skhdConfig = mkOption {
type = types.lines;
default = "";
example = "alt + shift - r : chunkc quit";
description = "Config to use for {file}`skhdrc`.";
};
};

config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
errorLogFile = mkOption {
type = types.path;
default = "/tmp/skhd.err.log";
example = "/Users/khaneliman/Library/Logs/skhd.log";
description = "Path to the error log file.";
};

outLogFile = mkOption {
type = types.path;
default = "/tmp/skhd.out.log";
example = "/Users/khaneliman/Library/Logs/skhd.log";
description = "Path to the stdout log file.";
};
};

environment.etc."skhdrc".text = cfg.skhdConfig;
config = lib.mkIf cfg.enable {
environment = {
systemPackages = [ cfg.package ];
etc."skhdrc".text = cfg.skhdConfig;
};

launchd.user.agents.skhd = {
path = [ config.environment.systemPath ];

serviceConfig.ProgramArguments = [ "${cfg.package}/bin/skhd" ]
++ optionals (cfg.skhdConfig != "") [ "-c" "/etc/skhdrc" ];
serviceConfig.KeepAlive = true;
serviceConfig.ProcessType = "Interactive";
serviceConfig = {
ProgramArguments =
[ "${cfg.package}/bin/skhd" ]
++ lib.optionals (cfg.skhdConfig != "") [
"-c"
"/etc/skhdrc"
];
KeepAlive = true;
ProcessType = "Interactive";
StandardErrorPath = cfg.errorLogFile;
StandardOutPath = cfg.outLogFile;
};
};

};
}