2019-09-15 21:12:08 +00:00
|
|
|
{config, lib, pkgs, ...}:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.sxhkd;
|
|
|
|
|
|
|
|
keybindingsStr = concatStringsSep "\n" (
|
|
|
|
mapAttrsToList (hotkey: command:
|
|
|
|
optionalString (command != null) ''
|
|
|
|
${hotkey}
|
|
|
|
${command}
|
|
|
|
''
|
|
|
|
)
|
|
|
|
cfg.keybindings
|
|
|
|
);
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2021-05-07 19:28:52 +00:00
|
|
|
imports = [
|
|
|
|
(mkRemovedOptionModule ["services" "sxhkd" "extraPath"]
|
|
|
|
"This option is no longer needed and can be removed.")
|
|
|
|
];
|
|
|
|
|
2019-09-15 21:12:08 +00:00
|
|
|
options.services.sxhkd = {
|
|
|
|
enable = mkEnableOption "simple X hotkey daemon";
|
|
|
|
|
2021-01-14 00:56:32 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.sxhkd;
|
|
|
|
defaultText = "pkgs.sxhkd";
|
|
|
|
description = "Package containing the <command>sxhkd</command> executable.";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
description = "Command line arguments to invoke <command>sxhkd</command> with.";
|
|
|
|
example = literalExample ''[ "-m 1" ]'';
|
|
|
|
};
|
|
|
|
|
2019-09-15 21:12:08 +00:00
|
|
|
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}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-05-07 19:28:52 +00:00
|
|
|
home.packages = [ cfg.package ];
|
2019-09-15 21:12:08 +00:00
|
|
|
|
|
|
|
xdg.configFile."sxhkd/sxhkdrc".text = concatStringsSep "\n" [
|
|
|
|
keybindingsStr
|
|
|
|
cfg.extraConfig
|
|
|
|
];
|
|
|
|
|
2021-05-07 19:28:52 +00:00
|
|
|
xsession.initExtra = ''
|
|
|
|
systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd \
|
|
|
|
${cfg.package}/bin/sxhkd ${toString cfg.extraOptions} &
|
|
|
|
'';
|
2019-09-15 21:12:08 +00:00
|
|
|
};
|
|
|
|
}
|