From 44d1a8542ac92f0ce75d970090216245043a2709 Mon Sep 17 00:00:00 2001 From: Kylie McClain Date: Fri, 30 Jun 2023 19:49:05 -0400 Subject: [PATCH] sxhkd: allow usage of derivations as keybind commands (#4169) This makes it consistent with some other options, like `systemd.user.services.Service.ExecStart`. --- modules/services/sxhkd.nix | 4 +++- tests/modules/services/sxhkd/configuration.nix | 14 ++++++++++++-- tests/modules/services/sxhkd/sxhkdrc | 3 +++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/services/sxhkd.nix b/modules/services/sxhkd.nix index 79f17e3cd..d308c95b4 100644 --- a/modules/services/sxhkd.nix +++ b/modules/services/sxhkd.nix @@ -38,13 +38,15 @@ in { }; keybindings = mkOption { - type = types.attrsOf (types.nullOr types.str); + 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"; } ''; }; diff --git a/tests/modules/services/sxhkd/configuration.nix b/tests/modules/services/sxhkd/configuration.nix index 9e9965051..7ca7b5307 100644 --- a/tests/modules/services/sxhkd/configuration.nix +++ b/tests/modules/services/sxhkd/configuration.nix @@ -1,6 +1,10 @@ { config, pkgs, ... }: -{ +let + script = pkgs.writeShellScript "script.sh" '' + echo "test" + ''; +in { services.sxhkd = { enable = true; @@ -10,6 +14,7 @@ "super + a" = "run command a"; "super + b" = null; "super + Shift + b" = "run command b"; + "super + s" = script; }; extraConfig = '' @@ -27,6 +32,11 @@ assertFileExists $sxhkdrc - assertFileContent $sxhkdrc ${./sxhkdrc} + assertFileContent $sxhkdrc ${ + pkgs.substituteAll { + src = ./sxhkdrc; + inherit script; + } + } ''; } diff --git a/tests/modules/services/sxhkd/sxhkdrc b/tests/modules/services/sxhkd/sxhkdrc index c8883464b..038253760 100644 --- a/tests/modules/services/sxhkd/sxhkdrc +++ b/tests/modules/services/sxhkd/sxhkdrc @@ -5,6 +5,9 @@ super + a run command a +super + s + @script@ + super + c call command c