From 10541f19c584fe9633c921903d8c095d5411e041 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Sun, 8 Sep 2024 11:10:43 -0400 Subject: [PATCH] pqiv: add boolean support --- modules/programs/pqiv.nix | 17 ++++++++++++----- tests/modules/programs/pqiv/settings.nix | 6 +++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/modules/programs/pqiv.nix b/modules/programs/pqiv.nix index ed1a0b280..a99b28de8 100644 --- a/modules/programs/pqiv.nix +++ b/modules/programs/pqiv.nix @@ -23,14 +23,13 @@ in { default = { }; description = '' Configuration written to {file}`$XDG_CONFIG_HOME/pqivrc`. See - {manpage}`pqiv(1)` for a list of available options. To set a - boolean flag, set the value to 1. + {manpage}`pqiv(1)` for a list of available options. ''; example = literalExpression '' { options = { - lazy-load = 1; - hide-info-box = 1; + lazy-load = true; + hide-info-box = true; background-pattern = "black"; thumbnail-size = "256x256"; command-1 = "thunar"; @@ -68,7 +67,15 @@ in { xdg.configFile."pqivrc" = mkIf (cfg.settings != { } && cfg.extraConfig != "") { text = lib.concatLines [ - (generators.toINI { } cfg.settings) + (generators.toINI { + mkKeyValue = key: value: + let + value' = if isBool value then + (if value then "1" else "0") + else + toString value; + in "${key} = ${value'}"; + } cfg.settings) cfg.extraConfig ]; }; diff --git a/tests/modules/programs/pqiv/settings.nix b/tests/modules/programs/pqiv/settings.nix index 277203da5..117fa6f04 100644 --- a/tests/modules/programs/pqiv/settings.nix +++ b/tests/modules/programs/pqiv/settings.nix @@ -6,7 +6,7 @@ package = config.lib.test.mkStubPackage { name = "pqiv"; }; settings = { options = { - hide-info-box = 1; + hide-info-box = true; thumbnail-size = "256x256"; }; }; @@ -21,8 +21,8 @@ assertFileContent home-files/.config/pqivrc ${ builtins.toFile "pqiv.expected" '' [options] - hide-info-box=1 - thumbnail-size=256x256 + hide-info-box = 1 + thumbnail-size = 256x256 [keybindings] t { montage_mode_enter() }