mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-31 04:04:32 +00:00
skhd: add module (#6682)
This commit is contained in:
parent
7853236fae
commit
9172a6f956
6 changed files with 121 additions and 1 deletions
|
@ -398,6 +398,7 @@ let
|
|||
./services/screen-locker.nix
|
||||
./services/sctd.nix
|
||||
./services/signaturepdf.nix
|
||||
./services/skhd.nix
|
||||
./services/snixembed.nix
|
||||
./services/spotifyd.nix
|
||||
./services/ssh-agent.nix
|
||||
|
|
83
modules/services/skhd.nix
Normal file
83
modules/services/skhd.nix
Normal file
|
@ -0,0 +1,83 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
let cfg = config.services.skhd;
|
||||
in {
|
||||
meta.maintainers = [ lib.maintainers.khaneliman ];
|
||||
|
||||
options.services.skhd = {
|
||||
enable = lib.mkEnableOption "skhd";
|
||||
|
||||
package = lib.mkPackageOption pkgs "skhd" { };
|
||||
|
||||
errorLogFile = lib.mkOption {
|
||||
type = with lib.types; nullOr (either path str);
|
||||
defaultText = lib.literalExpression
|
||||
"\${config.home.homeDirectory}/Library/Logs/skhd/err.log";
|
||||
example = "/Users/khaneliman/Library/Logs/skhd.log";
|
||||
description = "Absolute path to log all stderr output.";
|
||||
};
|
||||
|
||||
outLogFile = lib.mkOption {
|
||||
type = with lib.types; nullOr (either path str);
|
||||
defaultText = lib.literalExpression
|
||||
"\${config.home.homeDirectory}/Library/Logs/skhd/out.log";
|
||||
example = "/Users/khaneliman/Library/Logs/skhd.log";
|
||||
description = "Absolute path to log all stdout output.";
|
||||
};
|
||||
|
||||
config = lib.mkOption {
|
||||
type = with lib.types; nullOr (either path lines);
|
||||
default = null;
|
||||
example = ''
|
||||
# open terminal, blazingly fast compared to iTerm/Hyper
|
||||
cmd - return : /Applications/kitty.app/Contents/MacOS/kitty --single-instance -d ~
|
||||
|
||||
# open qutebrowser
|
||||
cmd + shift - return : ~/Scripts/qtb.sh
|
||||
|
||||
# open mpv
|
||||
cmd - m : open -na /Applications/mpv.app $(pbpaste)
|
||||
'';
|
||||
description = ''
|
||||
Contents of skhd's configuration file. If empty (the default), the configuration file won't be managed.
|
||||
|
||||
See [documentation](https://github.com/koekeishiya/skhd)
|
||||
and [example](https://github.com/koekeishiya/skhd/blob/master/examples/skhdrc).
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
(lib.hm.assertions.assertPlatform "services.skhd" pkgs
|
||||
lib.platforms.darwin)
|
||||
];
|
||||
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
launchd.agents.skhd = {
|
||||
enable = true;
|
||||
config = {
|
||||
ProgramArguments = [ (lib.getExe cfg.package) ];
|
||||
ProcessType = "Interactive";
|
||||
KeepAlive = true;
|
||||
RunAtLoad = true;
|
||||
StandardErrorPath = cfg.errorLogFile;
|
||||
StandardOutPath = cfg.outLogFile;
|
||||
};
|
||||
};
|
||||
|
||||
services.skhd = {
|
||||
errorLogFile = lib.mkOptionDefault
|
||||
"${config.home.homeDirectory}/Library/Logs/skhd/skhd.err.log";
|
||||
outLogFile = lib.mkOptionDefault
|
||||
"${config.home.homeDirectory}/Library/Logs/skhd/skhd.out.log";
|
||||
};
|
||||
|
||||
xdg.configFile."skhd/skhdrc" = lib.mkIf (cfg.config != null) {
|
||||
source = if builtins.isPath cfg.config || lib.isStorePath cfg.config then
|
||||
cfg.config
|
||||
else
|
||||
pkgs.writeScript "skhdrc" cfg.config;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -169,6 +169,7 @@ let
|
|||
"senpai"
|
||||
"sftpman"
|
||||
"sioyek"
|
||||
"skhd"
|
||||
"sm64ex"
|
||||
"spotify-player"
|
||||
"starship"
|
||||
|
@ -420,9 +421,10 @@ in import nmtSrc {
|
|||
./modules/services/git-sync-darwin
|
||||
./modules/services/imapnotify-darwin
|
||||
./modules/services/jankyborders
|
||||
./modules/services/nix-gc-darwin
|
||||
./modules/services/macos-remap-keys
|
||||
./modules/services/nix-gc-darwin
|
||||
./modules/services/ollama/darwin
|
||||
./modules/services/skhd
|
||||
./modules/services/yubikey-agent-darwin
|
||||
./modules/targets-darwin
|
||||
] ++ lib.optionals isLinux [
|
||||
|
|
25
tests/modules/services/skhd/config.nix
Normal file
25
tests/modules/services/skhd/config.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
services.skhd = {
|
||||
enable = true;
|
||||
config = ''
|
||||
# open terminal, blazingly fast compared to iTerm/Hyper
|
||||
cmd - return : /Applications/kitty.app/Contents/MacOS/kitty --single-instance -d ~
|
||||
|
||||
# open qutebrowser
|
||||
cmd + shift - return : ~/Scripts/qtb.sh
|
||||
|
||||
# open mpv
|
||||
cmd - m : open -na /Applications/mpv.app $(pbpaste)
|
||||
'';
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
configFile=home-files/.config/skhd/skhdrc
|
||||
assertFileExists $configFile
|
||||
assertFileIsExecutable "$configFile"
|
||||
assertFileContent $configFile ${./skhd-config-expected}
|
||||
|
||||
serviceFile=LaunchAgents/org.nix-community.home.skhd.plist
|
||||
assertFileExists "$serviceFile"
|
||||
'';
|
||||
}
|
1
tests/modules/services/skhd/default.nix
Normal file
1
tests/modules/services/skhd/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ skhd-basic-config = ./config.nix; }
|
8
tests/modules/services/skhd/skhd-config-expected
Normal file
8
tests/modules/services/skhd/skhd-config-expected
Normal file
|
@ -0,0 +1,8 @@
|
|||
# open terminal, blazingly fast compared to iTerm/Hyper
|
||||
cmd - return : /Applications/kitty.app/Contents/MacOS/kitty --single-instance -d ~
|
||||
|
||||
# open qutebrowser
|
||||
cmd + shift - return : ~/Scripts/qtb.sh
|
||||
|
||||
# open mpv
|
||||
cmd - m : open -na /Applications/mpv.app $(pbpaste)
|
Loading…
Add table
Reference in a new issue