1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00
home-manager/modules/programs/pqiv.nix

84 lines
2.1 KiB
Nix
Raw Normal View History

2023-07-03 20:30:13 +02:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.pqiv;
iniFormat = pkgs.formats.ini { };
in {
2024-03-10 10:20:21 +01:00
meta.maintainers = with lib.maintainers; [ donovanglover iynaix ];
2023-07-03 20:30:13 +02:00
options.programs.pqiv = {
enable = mkEnableOption "pqiv image viewer";
package = mkOption {
type = types.package;
default = pkgs.pqiv;
defaultText = literalExpression "pkgs.pqiv";
description = "The pqiv package to install.";
};
settings = mkOption {
type = iniFormat.type;
default = { };
description = ''
2024-03-10 10:20:21 +01:00
Configuration written to {file}`$XDG_CONFIG_HOME/pqivrc`. See
2024-09-08 17:10:43 +02:00
{manpage}`pqiv(1)` for a list of available options.
2023-07-03 20:30:13 +02:00
'';
example = literalExpression ''
{
options = {
2024-09-08 17:10:43 +02:00
lazy-load = true;
hide-info-box = true;
2023-07-03 20:30:13 +02:00
background-pattern = "black";
thumbnail-size = "256x256";
command-1 = "thunar";
};
};
'';
};
2024-03-10 10:20:21 +01:00
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() }
}
'';
};
2023-07-03 20:30:13 +02:00
};
config = mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "programs.pqiv" pkgs platforms.linux) ];
home.packages = [ cfg.package ];
2024-03-10 10:20:21 +01:00
xdg.configFile."pqivrc" =
mkIf (cfg.settings != { } && cfg.extraConfig != "") {
text = lib.concatLines [
2024-09-08 17:10:43 +02:00
(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)
2024-03-10 10:20:21 +01:00
cfg.extraConfig
];
};
2023-07-03 20:30:13 +02:00
};
}