2020-02-01 23:39:17 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2018-09-13 16:25:53 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.zathura;
|
|
|
|
|
|
|
|
formatLine = n: v:
|
|
|
|
let
|
|
|
|
formatValue = v:
|
2020-02-01 23:39:17 +00:00
|
|
|
if isBool v then (if v then "true" else "false") else toString v;
|
|
|
|
in ''set ${n} "${formatValue v}"'';
|
2018-09-13 16:25:53 +00:00
|
|
|
|
2022-08-12 14:32:15 +00:00
|
|
|
formatMapLine = n: v: "map ${n} ${toString v}";
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
in {
|
2018-09-13 16:25:53 +00:00
|
|
|
meta.maintainers = [ maintainers.rprospero ];
|
|
|
|
|
|
|
|
options.programs.zathura = {
|
2023-07-01 23:45:18 +00:00
|
|
|
enable = mkEnableOption ''
|
2018-10-02 06:17:34 +00:00
|
|
|
Zathura, a highly customizable and functional document viewer
|
2023-07-01 23:45:18 +00:00
|
|
|
focused on keyboard interaction'';
|
2018-09-13 16:25:53 +00:00
|
|
|
|
2020-12-04 17:38:22 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.zathura;
|
|
|
|
defaultText = "pkgs.zathura";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "The Zathura package to use";
|
2020-12-04 17:38:22 +00:00
|
|
|
};
|
|
|
|
|
2018-09-13 16:25:53 +00:00
|
|
|
options = mkOption {
|
2020-02-01 23:39:17 +00:00
|
|
|
default = { };
|
2018-09-13 16:25:53 +00:00
|
|
|
type = with types; attrsOf (either str (either bool int));
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2023-06-30 23:30:13 +00:00
|
|
|
Add {option}`:set` command options to zathura and make
|
2018-09-13 16:25:53 +00:00
|
|
|
them permanent. See
|
2023-06-30 23:30:13 +00:00
|
|
|
{manpage}`zathurarc(5)`
|
2018-09-13 16:25:53 +00:00
|
|
|
for the full list of options.
|
|
|
|
'';
|
2020-02-01 23:39:17 +00:00
|
|
|
example = {
|
|
|
|
default-bg = "#000000";
|
|
|
|
default-fg = "#FFFFFF";
|
|
|
|
};
|
2018-09-13 16:25:53 +00:00
|
|
|
};
|
|
|
|
|
2022-08-12 14:32:15 +00:00
|
|
|
mappings = mkOption {
|
|
|
|
default = { };
|
|
|
|
type = with types; attrsOf str;
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2023-06-30 23:30:13 +00:00
|
|
|
Add {option}`:map` mappings to zathura and make
|
2022-08-12 14:32:15 +00:00
|
|
|
them permanent. See
|
2023-06-30 23:30:13 +00:00
|
|
|
{manpage}`zathurarc(5)`
|
2022-08-12 14:32:15 +00:00
|
|
|
for the full list of possible mappings.
|
2023-03-22 09:50:13 +00:00
|
|
|
|
|
|
|
You can create a mode-specific mapping by specifying the mode before the key:
|
2023-06-30 23:30:13 +00:00
|
|
|
`"[normal] <C-b>" = "scroll left";`
|
2022-08-12 14:32:15 +00:00
|
|
|
'';
|
|
|
|
example = {
|
|
|
|
D = "toggle_page_mode";
|
|
|
|
"<Right>" = "navigate next";
|
2023-03-22 09:50:13 +00:00
|
|
|
"[fullscreen] <C-i>" = "zoom in";
|
2022-08-12 14:32:15 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-09-13 16:25:53 +00:00
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2018-09-13 16:25:53 +00:00
|
|
|
Additional commands for zathura that will be added to the
|
2023-06-30 23:30:13 +00:00
|
|
|
{file}`zathurarc` file.
|
2018-09-13 16:25:53 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2020-12-04 17:38:22 +00:00
|
|
|
home.packages = [ cfg.package ];
|
2018-09-13 16:25:53 +00:00
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
xdg.configFile."zathura/zathurarc".text = concatStringsSep "\n" ([ ]
|
|
|
|
++ optional (cfg.extraConfig != "") cfg.extraConfig
|
2022-08-12 14:32:15 +00:00
|
|
|
++ mapAttrsToList formatLine cfg.options
|
|
|
|
++ mapAttrsToList formatMapLine cfg.mappings) + "\n";
|
2018-09-13 16:25:53 +00:00
|
|
|
};
|
|
|
|
}
|