i3/sway: allow empty criterias using a value of 'true' (#2277)

Co-authored-by: Sumner Evans <me@sumnerevans.com>
This commit is contained in:
Nicolas Berbiche 2021-08-21 20:41:06 -04:00 committed by GitHub
parent 4367119ca3
commit c5b3069145
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 7 deletions

View file

@ -4,9 +4,13 @@ with lib;
rec { rec {
criteriaStr = criteria: criteriaStr = criteria:
"[${ let
concatStringsSep " " (mapAttrsToList (k: v: ''${k}="${v}"'') criteria) 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: keybindingDefaultWorkspace = filterAttrs (n: v:
cfg.config.defaultWorkspace != null && v == cfg.config.defaultWorkspace) cfg.config.defaultWorkspace != null && v == cfg.config.defaultWorkspace)

View file

@ -353,14 +353,23 @@ let
criteria = mkOption { criteria = mkOption {
type = criteriaModule; type = criteriaModule;
description = description = ''
"Criteria of the windows on which command should be executed."; Criteria of the windows on which command should be executed.
example = { title = "x200: ~/work"; }; </para><para>
A value of <literal>true</literal> 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 { in {
fonts = mkOption { fonts = mkOption {
type = with types; either (listOf str) fontOptions; type = with types; either (listOf str) fontOptions;