pqiv: add extraConfig option

This commit is contained in:
Lin Xianyi 2024-03-10 17:20:21 +08:00 committed by GitHub
parent fe4180ad3f
commit 36f873dfc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 10 deletions

View File

@ -3,12 +3,10 @@
with lib;
let
cfg = config.programs.pqiv;
iniFormat = pkgs.formats.ini { };
in {
meta.maintainers = with lib.maintainers; [ donovanglover ];
meta.maintainers = with lib.maintainers; [ donovanglover iynaix ];
options.programs.pqiv = {
enable = mkEnableOption "pqiv image viewer";
@ -24,10 +22,9 @@ in {
type = iniFormat.type;
default = { };
description = ''
Configuration written to
<filename>$XDG_CONFIG_HOME/pqivrc</filename>. See <link
xlink:href="https://github.com/phillipberndt/pqiv/blob/master/pqiv.1"/>
for a list of available options. To set a boolean flag, set the value to 1.
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.
'';
example = literalExpression ''
{
@ -41,6 +38,25 @@ in {
};
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = ''
Extra lines to be added to {file}`$XDG_CONFIG_HOME/pqivrc`. See
{manpage}`pqiv(1)` for a list of available options.
'';
example = literalExpression ''
[actions]
set_cursor_auto_hide(1)
[keybindings]
t { montage_mode_enter() }
@MONTAGE {
t { montage_mode_return_cancel() }
}
'';
};
};
config = mkIf cfg.enable {
@ -49,8 +65,12 @@ in {
home.packages = [ cfg.package ];
xdg.configFile."pqivrc" = mkIf (cfg.settings != { }) {
source = iniFormat.generate "pqivrc" cfg.settings;
};
xdg.configFile."pqivrc" =
mkIf (cfg.settings != { } && cfg.extraConfig != "") {
text = lib.concatLines [
(generators.toINI { } cfg.settings)
cfg.extraConfig
];
};
};
}

View File

@ -10,6 +10,10 @@
thumbnail-size = "256x256";
};
};
extraConfig = ''
[keybindings]
t { montage_mode_enter() }
'';
};
nmt.script = ''
@ -19,6 +23,10 @@
[options]
hide-info-box=1
thumbnail-size=256x256
[keybindings]
t { montage_mode_enter() }
''
}
'';