From c5b3069145806965ff2bf3807cf273a5a36dc23c Mon Sep 17 00:00:00 2001 From: Nicolas Berbiche Date: Sat, 21 Aug 2021 20:41:06 -0400 Subject: [PATCH] i3/sway: allow empty criterias using a value of 'true' (#2277) Co-authored-by: Sumner Evans --- .../window-managers/i3-sway/lib/functions.nix | 10 +++++++--- .../window-managers/i3-sway/lib/options.nix | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/modules/services/window-managers/i3-sway/lib/functions.nix b/modules/services/window-managers/i3-sway/lib/functions.nix index 3cb7eca59..75b3f7b6f 100644 --- a/modules/services/window-managers/i3-sway/lib/functions.nix +++ b/modules/services/window-managers/i3-sway/lib/functions.nix @@ -4,9 +4,13 @@ with lib; rec { criteriaStr = criteria: - "[${ - concatStringsSep " " (mapAttrsToList (k: v: ''${k}="${v}"'') criteria) - }]"; + let + toCriteria = k: v: + if builtins.isBool v then + (if v then "${k}" else "") + else + ''${k}="${v}"''; + in "[${concatStringsSep " " (mapAttrsToList toCriteria criteria)}]"; keybindingDefaultWorkspace = filterAttrs (n: v: cfg.config.defaultWorkspace != null && v == cfg.config.defaultWorkspace) diff --git a/modules/services/window-managers/i3-sway/lib/options.nix b/modules/services/window-managers/i3-sway/lib/options.nix index 478fc856c..1dcb330ef 100644 --- a/modules/services/window-managers/i3-sway/lib/options.nix +++ b/modules/services/window-managers/i3-sway/lib/options.nix @@ -353,14 +353,23 @@ let criteria = mkOption { type = criteriaModule; - description = - "Criteria of the windows on which command should be executed."; - example = { title = "x200: ~/work"; }; + description = '' + Criteria of the windows on which command should be executed. + + A value of true is equivalent to using an empty + criteria (which is different from an empty string criteria). + ''; + example = literalExample '' + { + title = "x200: ~/work"; + floating = true; + }; + ''; }; }; }; - criteriaModule = types.attrsOf types.str; + criteriaModule = types.attrsOf (types.either types.str types.bool); in { fonts = mkOption { type = with types; either (listOf str) fontOptions;