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 {
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)

View file

@ -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.
</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 {
fonts = mkOption {
type = with types; either (listOf str) fontOptions;