mirror of
https://github.com/nix-community/home-manager
synced 2025-01-11 11:39:49 +01:00
sxhkd: add service
This commit is contained in:
parent
b0544c8cde
commit
51581b7e43
8 changed files with 164 additions and 0 deletions
|
@ -1185,6 +1185,14 @@ in
|
||||||
Specifying them as strings is deprecated.
|
Specifying them as strings is deprecated.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
time = "2019-09-17T19:33:49+00:00";
|
||||||
|
condition = hostPlatform.isLinux;
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'services.sxhkd'.
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,7 @@ let
|
||||||
(loadModule ./services/screen-locker.nix { })
|
(loadModule ./services/screen-locker.nix { })
|
||||||
(loadModule ./services/stalonetray.nix { })
|
(loadModule ./services/stalonetray.nix { })
|
||||||
(loadModule ./services/status-notifier-watcher.nix { })
|
(loadModule ./services/status-notifier-watcher.nix { })
|
||||||
|
(loadModule ./services/sxhkd.nix { condition = hostPlatform.isLinux; })
|
||||||
(loadModule ./services/syncthing.nix { })
|
(loadModule ./services/syncthing.nix { })
|
||||||
(loadModule ./services/taffybar.nix { })
|
(loadModule ./services/taffybar.nix { })
|
||||||
(loadModule ./services/tahoe-lafs.nix { })
|
(loadModule ./services/tahoe-lafs.nix { })
|
||||||
|
|
86
modules/services/sxhkd.nix
Normal file
86
modules/services/sxhkd.nix
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
{config, lib, pkgs, ...}:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
cfg = config.services.sxhkd;
|
||||||
|
|
||||||
|
keybindingsStr = concatStringsSep "\n" (
|
||||||
|
mapAttrsToList (hotkey: command:
|
||||||
|
optionalString (command != null) ''
|
||||||
|
${hotkey}
|
||||||
|
${command}
|
||||||
|
''
|
||||||
|
)
|
||||||
|
cfg.keybindings
|
||||||
|
);
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
options.services.sxhkd = {
|
||||||
|
enable = mkEnableOption "simple X hotkey daemon";
|
||||||
|
|
||||||
|
keybindings = mkOption {
|
||||||
|
type = types.attrsOf (types.nullOr types.str);
|
||||||
|
default = {};
|
||||||
|
description = "An attribute set that assigns hotkeys to commands.";
|
||||||
|
example = literalExample ''
|
||||||
|
{
|
||||||
|
"super + shift + {r,c}" = "i3-msg {restart,reload}";
|
||||||
|
"super + {s,w}" = "i3-msg {stacking,tabbed}";
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = mkOption {
|
||||||
|
default = "";
|
||||||
|
type = types.lines;
|
||||||
|
description = "Additional configuration to add.";
|
||||||
|
example = literalExample ''
|
||||||
|
super + {_,shift +} {1-9,0}
|
||||||
|
i3-msg {workspace,move container to workspace} {1-10}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
extraPath = mkOption {
|
||||||
|
default = "";
|
||||||
|
type = types.envVar;
|
||||||
|
description = ''
|
||||||
|
Additional <envar>PATH</envar> entries to search for commands.
|
||||||
|
'';
|
||||||
|
example = "/home/some-user/bin:/extra/path/bin";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
home.packages = [ pkgs.sxhkd ];
|
||||||
|
|
||||||
|
xdg.configFile."sxhkd/sxhkdrc".text = concatStringsSep "\n" [
|
||||||
|
keybindingsStr
|
||||||
|
cfg.extraConfig
|
||||||
|
];
|
||||||
|
|
||||||
|
systemd.user.services.sxhkd = {
|
||||||
|
Unit = {
|
||||||
|
Description = "simple X hotkey daemon";
|
||||||
|
After = [ "graphical-session-pre.target" ];
|
||||||
|
PartOf = [ "graphical-session.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
Environment =
|
||||||
|
"PATH="
|
||||||
|
+ "${config.home.profileDirectory}/bin"
|
||||||
|
+ optionalString (cfg.extraPath != "") ":"
|
||||||
|
+ cfg.extraPath;
|
||||||
|
ExecStart = "${pkgs.sxhkd}/bin/sxhkd";
|
||||||
|
};
|
||||||
|
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "graphical-session.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -38,6 +38,7 @@ import nmt {
|
||||||
// import ./modules/misc/xsession
|
// import ./modules/misc/xsession
|
||||||
// import ./modules/programs/firefox
|
// import ./modules/programs/firefox
|
||||||
// import ./modules/programs/rofi
|
// import ./modules/programs/rofi
|
||||||
|
// import ./modules/services/sxhkd
|
||||||
// import ./modules/systemd
|
// import ./modules/systemd
|
||||||
)
|
)
|
||||||
// import ./modules/home-environment
|
// import ./modules/home-environment
|
||||||
|
|
31
tests/modules/services/sxhkd/configuration.nix
Normal file
31
tests/modules/services/sxhkd/configuration.nix
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
services.sxhkd = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
keybindings = {
|
||||||
|
"super + a" = "run command a";
|
||||||
|
"super + b" = null;
|
||||||
|
"super + Shift + b" = "run command b";
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = ''
|
||||||
|
super + c
|
||||||
|
call command c
|
||||||
|
|
||||||
|
# comment
|
||||||
|
super + d
|
||||||
|
call command d
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
local sxhkdrc=home-files/.config/sxhkd/sxhkdrc
|
||||||
|
|
||||||
|
assertFileExists $sxhkdrc
|
||||||
|
|
||||||
|
assertFileContent $sxhkdrc ${./sxhkdrc}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
4
tests/modules/services/sxhkd/default.nix
Normal file
4
tests/modules/services/sxhkd/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
sxhkd-configuration = ./configuration.nix;
|
||||||
|
sxhkd-service = ./service.nix;
|
||||||
|
}
|
20
tests/modules/services/sxhkd/service.nix
Normal file
20
tests/modules/services/sxhkd/service.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
services.sxhkd = {
|
||||||
|
enable = true;
|
||||||
|
extraPath = "/home/the-user/bin:/extra/path/bin";
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
local serviceFile=home-files/.config/systemd/user/sxhkd.service
|
||||||
|
|
||||||
|
assertFileExists $serviceFile
|
||||||
|
|
||||||
|
assertFileRegex $serviceFile 'ExecStart=.*/bin/sxhkd'
|
||||||
|
|
||||||
|
assertFileRegex $serviceFile \
|
||||||
|
'Environment=PATH=.*\.nix-profile/bin:/home/the-user/bin:/extra/path/bin'
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
13
tests/modules/services/sxhkd/sxhkdrc
Normal file
13
tests/modules/services/sxhkd/sxhkdrc
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
super + Shift + b
|
||||||
|
run command b
|
||||||
|
|
||||||
|
super + a
|
||||||
|
run command a
|
||||||
|
|
||||||
|
|
||||||
|
super + c
|
||||||
|
call command c
|
||||||
|
|
||||||
|
# comment
|
||||||
|
super + d
|
||||||
|
call command d
|
Loading…
Reference in a new issue