2017-09-04 14:35:23 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.feh;
|
|
|
|
|
|
|
|
disableBinding = func: key: func;
|
2020-01-30 09:44:54 +00:00
|
|
|
enableBinding = func: key: "${func} ${toString key}";
|
2017-09-04 14:35:23 +00:00
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
in {
|
2017-09-04 14:35:23 +00:00
|
|
|
options.programs.feh = {
|
|
|
|
enable = mkEnableOption "feh - a fast and light image viewer";
|
|
|
|
|
2020-01-30 09:44:54 +00:00
|
|
|
buttons = mkOption {
|
2020-02-01 23:39:17 +00:00
|
|
|
default = { };
|
2020-01-30 09:44:54 +00:00
|
|
|
type = with types; attrsOf (nullOr (either str int));
|
2020-02-01 23:39:17 +00:00
|
|
|
example = {
|
|
|
|
zoom_in = 4;
|
|
|
|
zoom_out = "C-4";
|
|
|
|
};
|
2020-01-30 09:44:54 +00:00
|
|
|
description = ''
|
|
|
|
Override feh's default mouse button mapping. If you want to disable an
|
2020-02-01 23:39:17 +00:00
|
|
|
action, set its value to null.
|
2020-01-30 09:44:54 +00:00
|
|
|
See <link xlink:href="https://man.finalrewind.org/1/feh/#x425554544f4e53"/> for
|
|
|
|
default bindings and available commands.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-09-04 14:35:23 +00:00
|
|
|
keybindings = mkOption {
|
2020-02-01 23:39:17 +00:00
|
|
|
default = { };
|
2020-01-30 09:44:54 +00:00
|
|
|
type = types.attrsOf (types.nullOr types.str);
|
2020-02-01 23:39:17 +00:00
|
|
|
example = {
|
|
|
|
zoom_in = "plus";
|
|
|
|
zoom_out = "minus";
|
|
|
|
};
|
2017-09-04 14:35:23 +00:00
|
|
|
description = ''
|
2020-01-30 09:44:54 +00:00
|
|
|
Override feh's default keybindings. If you want to disable a keybinding
|
2020-02-01 23:39:17 +00:00
|
|
|
set its value to null.
|
2017-09-04 14:35:23 +00:00
|
|
|
See <link xlink:href="https://man.finalrewind.org/1/feh/#x4b455953"/> for
|
|
|
|
default bindings and available commands.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2020-02-01 23:39:17 +00:00
|
|
|
assertions = [{
|
|
|
|
assertion = ((filterAttrs (n: v: v == "") cfg.keybindings) == { });
|
|
|
|
message =
|
|
|
|
"To disable a keybinding, use `null` instead of an empty string.";
|
|
|
|
}];
|
2020-01-30 09:44:54 +00:00
|
|
|
|
2017-09-04 14:35:23 +00:00
|
|
|
home.packages = [ pkgs.feh ];
|
|
|
|
|
2020-01-30 09:44:54 +00:00
|
|
|
xdg.configFile."feh/buttons".text = ''
|
2020-02-01 23:39:17 +00:00
|
|
|
${concatStringsSep "\n" (mapAttrsToList disableBinding
|
|
|
|
(filterAttrs (n: v: v == null) cfg.buttons))}
|
|
|
|
${concatStringsSep "\n" (mapAttrsToList enableBinding
|
|
|
|
(filterAttrs (n: v: v != null) cfg.buttons))}
|
2020-01-30 09:44:54 +00:00
|
|
|
'';
|
2017-09-04 14:35:23 +00:00
|
|
|
|
2020-01-30 09:44:54 +00:00
|
|
|
xdg.configFile."feh/keys".text = ''
|
2020-02-01 23:39:17 +00:00
|
|
|
${concatStringsSep "\n" (mapAttrsToList disableBinding
|
|
|
|
(filterAttrs (n: v: v == null) cfg.keybindings))}
|
|
|
|
${concatStringsSep "\n" (mapAttrsToList enableBinding
|
|
|
|
(filterAttrs (n: v: v != null) cfg.keybindings))}
|
2017-09-04 14:35:23 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|