mirror of
https://github.com/nix-community/home-manager
synced 2024-12-26 03:39:47 +01:00
9f9e277b60
These (and the `*MD` functions apart from `literalMD`) are now no-ops in nixpkgs and serve no purpose other than to add additional noise and potentially mislead people into thinking unmarked DocBook documentation will still be accepted. Note that if backporting changes including documentation to 23.05, the `mdDoc` calls will need to be re-added. To reproduce this commit, run: $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \ nix shell nixpkgs#coreutils \ -c find . -name '*.nix' \ -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \ --strip {} + $ ./format
81 lines
2.2 KiB
Nix
81 lines
2.2 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.sxhkd;
|
|
|
|
keybindingsStr = concatStringsSep "\n" (mapAttrsToList (hotkey: command:
|
|
optionalString (command != null) ''
|
|
${hotkey}
|
|
${command}
|
|
'') cfg.keybindings);
|
|
|
|
in {
|
|
imports = [
|
|
(mkRemovedOptionModule [ "services" "sxhkd" "extraPath" ]
|
|
"This option is no longer needed and can be removed.")
|
|
];
|
|
|
|
options.services.sxhkd = {
|
|
enable = mkEnableOption "simple X hotkey daemon";
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.sxhkd;
|
|
defaultText = "pkgs.sxhkd";
|
|
description = "Package containing the {command}`sxhkd` executable.";
|
|
};
|
|
|
|
extraOptions = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ ];
|
|
description = "Command line arguments to invoke {command}`sxhkd` with.";
|
|
example = literalExpression ''[ "-m 1" ]'';
|
|
};
|
|
|
|
keybindings = mkOption {
|
|
type =
|
|
types.attrsOf (types.nullOr (types.oneOf [ types.str types.path ]));
|
|
default = { };
|
|
description = "An attribute set that assigns hotkeys to commands.";
|
|
example = literalExpression ''
|
|
{
|
|
"super + shift + {r,c}" = "i3-msg {restart,reload}";
|
|
"super + {s,w}" = "i3-msg {stacking,tabbed}";
|
|
"super + F1" = pkgs.writeShellScript "script" "echo $USER";
|
|
}
|
|
'';
|
|
};
|
|
|
|
extraConfig = mkOption {
|
|
default = "";
|
|
type = types.lines;
|
|
description = "Additional configuration to add.";
|
|
example = literalExpression ''
|
|
super + {_,shift +} {1-9,0}
|
|
i3-msg {workspace,move container to workspace} {1-10}
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "services.sxhkd" pkgs
|
|
lib.platforms.linux)
|
|
];
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
xdg.configFile."sxhkd/sxhkdrc".text =
|
|
concatStringsSep "\n" [ keybindingsStr cfg.extraConfig ];
|
|
|
|
xsession.initExtra = let
|
|
sxhkdCommand = "${cfg.package}/bin/sxhkd ${toString cfg.extraOptions}";
|
|
in ''
|
|
systemctl --user stop sxhkd.scope 2> /dev/null || true
|
|
systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd ${sxhkdCommand} &
|
|
'';
|
|
};
|
|
}
|