hyprland: allow closing submaps on dispatch
This adds an 'onDispatch' option to the 'submaps' attribute set, enabling the 'submap = name, ondispatch' syntax which allows submaps to be closed automatically after a dispatch.
This commit is contained in:
parent
9d83727001
commit
2b9504d5a0
4 changed files with 47 additions and 4 deletions
|
|
@ -238,6 +238,14 @@ in
|
|||
{ name, config, ... }:
|
||||
{
|
||||
options = {
|
||||
onDispatch = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
description = ''
|
||||
Submap to use after a dispatch. Can either be a name or `reset` to disable submap after any dispatch.
|
||||
'';
|
||||
example = "reset";
|
||||
};
|
||||
settings = lib.mkOption {
|
||||
type = (with lib.types; attrsOf (listOf str)) // {
|
||||
description = "Hyprland binds";
|
||||
|
|
@ -348,8 +356,11 @@ in
|
|||
warnings =
|
||||
let
|
||||
inconsistent =
|
||||
(cfg.systemd.enable || cfg.plugins != [ ]) && cfg.extraConfig == "" && cfg.settings == { };
|
||||
warning = "You have enabled hyprland.systemd.enable or listed plugins in hyprland.plugins but do not have any configuration in hyprland.settings or hyprland.extraConfig. This is almost certainly a mistake.";
|
||||
(cfg.systemd.enable || cfg.plugins != [ ])
|
||||
&& cfg.extraConfig == ""
|
||||
&& cfg.settings == { }
|
||||
&& cfg.submaps == { };
|
||||
warning = "You have enabled hyprland.systemd.enable or listed plugins in hyprland.plugins but do not have any configuration in hyprland.settings, hyprland.extraConfig or hyprland.submaps. This is almost certainly a mistake.";
|
||||
|
||||
filterNonBinds =
|
||||
attrs: builtins.filter (n: builtins.match "bind[[:lower:]]*" n == null) (builtins.attrNames attrs);
|
||||
|
|
@ -391,7 +402,7 @@ in
|
|||
};
|
||||
|
||||
mkSubMap = name: attrs: ''
|
||||
submap = ${name}
|
||||
submap = ${name}${lib.optionalString (attrs.onDispatch != "") ", ${attrs.onDispatch}"}
|
||||
${
|
||||
lib.hm.generators.toHyprconf {
|
||||
attrs = attrs.settings;
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@ lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
|||
hyprland-sourceFirst-false-config = ./sourceFirst-false-config.nix;
|
||||
hyprland-inconsistent-config = ./inconsistent-config.nix;
|
||||
hyprland-submaps-config = ./submaps-config.nix;
|
||||
hyprland-submaps-on-dispatch = ./submaps-on-dispatch.nix;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
};
|
||||
|
||||
test.asserts.warnings.expected = [
|
||||
"You have enabled hyprland.systemd.enable or listed plugins in hyprland.plugins but do not have any configuration in hyprland.settings or hyprland.extraConfig. This is almost certainly a mistake."
|
||||
"You have enabled hyprland.systemd.enable or listed plugins in hyprland.plugins but do not have any configuration in hyprland.settings, hyprland.extraConfig or hyprland.submaps. This is almost certainly a mistake."
|
||||
];
|
||||
test.asserts.warnings.enable = true;
|
||||
|
||||
|
|
|
|||
31
tests/modules/services/hyprland/submaps-on-dispatch.nix
Normal file
31
tests/modules/services/hyprland/submaps-on-dispatch.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
wayland.windowManager.hyprland = {
|
||||
enable = true;
|
||||
submaps = {
|
||||
resize = {
|
||||
onDispatch = "reset";
|
||||
settings = {
|
||||
binde = [
|
||||
", right, resizeactive, 10 0"
|
||||
", left, resizeactive, -10 0"
|
||||
];
|
||||
};
|
||||
};
|
||||
other = {
|
||||
onDispatch = "resize";
|
||||
settings = {
|
||||
bind = [ ", a, exec, true" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
config=home-files/.config/hypr/hyprland.conf
|
||||
assertFileExists "$config"
|
||||
assertFileContains "$config" "submap = resize, reset"
|
||||
assertFileContains "$config" "submap = other, resize"
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue