aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hoang <enzime@users.noreply.github.com>2020-01-30 20:44:54 +1100
committerNikita Uvarov <uv.nikita@gmail.com>2020-02-01 10:04:52 +0100
commit9799d3de2d270a9c40fcf81d600bfd71088e144d (patch)
tree6b19f240d36d0cb7ebab777683f2d99a6ddc7a80
parenta591e8f9e43463b2efb14a70edaf76ff1a2ebee4 (diff)
feh: add buttons option
Use `null` to disable keybindings or button mappings.
-rw-r--r--modules/programs/feh.nix38
1 files changed, 30 insertions, 8 deletions
diff --git a/modules/programs/feh.nix b/modules/programs/feh.nix
index 4342181fa4a..1b14e71f58f 100644
--- a/modules/programs/feh.nix
+++ b/modules/programs/feh.nix
@@ -7,7 +7,7 @@ let
cfg = config.programs.feh;
disableBinding = func: key: func;
- enableBinding = func: key: "${func} ${key}";
+ enableBinding = func: key: "${func} ${toString key}";
in
@@ -15,12 +15,25 @@ in
options.programs.feh = {
enable = mkEnableOption "feh - a fast and light image viewer";
+ buttons = mkOption {
+ default = {};
+ type = with types; attrsOf (nullOr (either str int));
+ example = { zoom_in = 4; zoom_out = "C-4"; };
+ description = ''
+ Override feh's default mouse button mapping. If you want to disable an
+ action, set its value to null.
+ See <link xlink:href="https://man.finalrewind.org/1/feh/#x425554544f4e53"/> for
+ default bindings and available commands.
+ '';
+ };
+
keybindings = mkOption {
default = {};
- type = types.attrsOf types.str;
+ type = types.attrsOf (types.nullOr types.str);
example = { zoom_in = "plus"; zoom_out = "minus"; };
description = ''
- Set keybindings.
+ Override feh's default keybindings. If you want to disable a keybinding
+ set its value to null.
See <link xlink:href="https://man.finalrewind.org/1/feh/#x4b455953"/> for
default bindings and available commands.
'';
@@ -28,14 +41,23 @@ in
};
config = mkIf cfg.enable {
+ assertions = [
+ {
+ assertion = ((filterAttrs (n: v: v == "") cfg.keybindings) == {});
+ message = "To disable a keybinding, use `null` instead of an empty string.";
+ }
+ ];
+
home.packages = [ pkgs.feh ];
- xdg.configFile."feh/keys".text = ''
- # Disable default keybindings
- ${concatStringsSep "\n" (mapAttrsToList disableBinding cfg.keybindings)}
+ xdg.configFile."feh/buttons".text = ''
+ ${concatStringsSep "\n" (mapAttrsToList disableBinding (filterAttrs (n: v: v == null) cfg.buttons))}
+ ${concatStringsSep "\n" (mapAttrsToList enableBinding (filterAttrs (n: v: v != null) cfg.buttons))}
+ '';
- # Enable new keybindings
- ${concatStringsSep "\n" (mapAttrsToList enableBinding cfg.keybindings)}
+ xdg.configFile."feh/keys".text = ''
+ ${concatStringsSep "\n" (mapAttrsToList disableBinding (filterAttrs (n: v: v == null) cfg.keybindings))}
+ ${concatStringsSep "\n" (mapAttrsToList enableBinding (filterAttrs (n: v: v != null) cfg.keybindings))}
'';
};
}