aboutsummaryrefslogtreecommitdiff
path: root/modules/programs/feh.nix
blob: 4342181fa4a571b070596e50dda2575c483b13d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.programs.feh;

  disableBinding = func: key: func;
  enableBinding = func: key: "${func} ${key}";

in

{
  options.programs.feh = {
    enable = mkEnableOption "feh - a fast and light image viewer";

    keybindings = mkOption {
      default = {};
      type = types.attrsOf types.str;
      example = { zoom_in = "plus"; zoom_out = "minus"; };
      description = ''
        Set keybindings.
        See <link xlink:href="https://man.finalrewind.org/1/feh/#x4b455953"/> for
        default bindings and available commands.
      '';
    };
  };

  config = mkIf cfg.enable {
    home.packages = [ pkgs.feh ];

    xdg.configFile."feh/keys".text = ''
      # Disable default keybindings
      ${concatStringsSep "\n" (mapAttrsToList disableBinding cfg.keybindings)}

      # Enable new keybindings
      ${concatStringsSep "\n" (mapAttrsToList enableBinding cfg.keybindings)}
    '';
  };
}