From 1d0862ee2d7c6f6cd720d6f32213fa425004be10 Mon Sep 17 00:00:00 2001 From: gmvar Date: Thu, 14 Nov 2024 09:16:21 -0800 Subject: [PATCH] feh: add themes option (#6074) - added themes option - added themes test - updated broken man page links --- modules/programs/feh.nix | 40 ++++++++++++++++++- tests/modules/programs/feh/default.nix | 1 + .../programs/feh/feh-empty-settings.nix | 1 + .../modules/programs/feh/feh-themes-expected | 6 +++ tests/modules/programs/feh/feh-themes.nix | 32 +++++++++++++++ 5 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 tests/modules/programs/feh/feh-themes-expected create mode 100644 tests/modules/programs/feh/feh-themes.nix diff --git a/modules/programs/feh.nix b/modules/programs/feh.nix index f44f184a3..bef9caac3 100644 --- a/modules/programs/feh.nix +++ b/modules/programs/feh.nix @@ -8,6 +8,12 @@ let bindingsOf = t: with types; attrsOf (nullOr (either t (listOf t))); + renderThemes = options: + let + render = + mapAttrsToList (theme: options: "${theme} ${escapeShellArgs options}"); + in concatStringsSep "\n" (render options); + renderBindings = bindings: let enabled = filterAttrs (n: v: v != null) bindings; @@ -41,7 +47,7 @@ in { Override feh's default mouse button mapping. If you want to disable an action, set its value to null. If you want to bind multiple buttons to an action, set its value to a list. - See for + See for default bindings and available commands. ''; }; @@ -58,10 +64,37 @@ in { Override feh's default keybindings. If you want to disable a keybinding set its value to null. If you want to bind multiple keys to an action, set its value to a list. - See for + See for default bindings and available commands. ''; }; + + themes = mkOption { + default = { }; + type = with types; attrsOf (listOf str); + example = { + feh = [ "--image-bg" "black" ]; + webcam = [ "--multiwindow" "--reload" "20" ]; + present = [ "--full-screen" "--sort" "name" "--hide-pointer" ]; + booth = [ "--full-screen" "--hide-pointer" "--slideshow-delay" "20" ]; + imagemap = [ + "-rVq" + "--thumb-width" + "40" + "--thumb-height" + "30" + "--index-info" + "%n\\n%wx%h" + ]; + example = [ "--info" "foo bar" ]; + }; + description = '' + Define themes for feh. + See for + important guidelines and limitations related to theme configuration. + ''; + }; + }; config = mkIf cfg.enable { @@ -79,5 +112,8 @@ in { xdg.configFile."feh/keys" = mkIf (cfg.keybindings != { }) { text = renderBindings cfg.keybindings + "\n"; }; + + xdg.configFile."feh/themes" = + mkIf (cfg.themes != { }) { text = renderThemes cfg.themes + "\n"; }; }; } diff --git a/tests/modules/programs/feh/default.nix b/tests/modules/programs/feh/default.nix index 48bab8ab6..e1051adcd 100644 --- a/tests/modules/programs/feh/default.nix +++ b/tests/modules/programs/feh/default.nix @@ -1,4 +1,5 @@ { feh-empty-config = ./feh-empty-settings.nix; feh-bindings = ./feh-bindings.nix; + feh-themes = ./feh-themes.nix; } diff --git a/tests/modules/programs/feh/feh-empty-settings.nix b/tests/modules/programs/feh/feh-empty-settings.nix index 62feb8230..9a50e20bf 100644 --- a/tests/modules/programs/feh/feh-empty-settings.nix +++ b/tests/modules/programs/feh/feh-empty-settings.nix @@ -9,6 +9,7 @@ nmt.script = '' assertPathNotExists home-files/.config/feh/buttons assertPathNotExists home-files/.config/feh/keys + assertPathNotExists home-files/.config/feh/themes ''; }; } diff --git a/tests/modules/programs/feh/feh-themes-expected b/tests/modules/programs/feh/feh-themes-expected new file mode 100644 index 000000000..5dce2792d --- /dev/null +++ b/tests/modules/programs/feh/feh-themes-expected @@ -0,0 +1,6 @@ +booth --full-screen --hide-pointer --slideshow-delay 20 +example --info 'foo bar' +feh --image-bg black +imagemap -rVq --thumb-width 40 --thumb-height 30 --index-info '%n\n%wx%h' +present --full-screen --sort name --hide-pointer +webcam --multiwindow --reload 20 diff --git a/tests/modules/programs/feh/feh-themes.nix b/tests/modules/programs/feh/feh-themes.nix new file mode 100644 index 000000000..f06ea0716 --- /dev/null +++ b/tests/modules/programs/feh/feh-themes.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: + +{ + config = { + programs.feh.enable = true; + + programs.feh.themes = { + feh = [ "--image-bg" "black" ]; + webcam = [ "--multiwindow" "--reload" "20" ]; + present = [ "--full-screen" "--sort" "name" "--hide-pointer" ]; + booth = [ "--full-screen" "--hide-pointer" "--slideshow-delay" "20" ]; + imagemap = [ + "-rVq" + "--thumb-width" + "40" + "--thumb-height" + "30" + "--index-info" + "%n\\n%wx%h" + ]; + example = [ "--info" "foo bar" ]; + }; + + test.stubs.feh = { }; + + nmt.script = '' + assertFileContent \ + home-files/.config/feh/themes \ + ${./feh-themes-expected} + ''; + }; +}