diff --git a/home/lib/wallpaper/buildWallpaper.nix b/home/lib/wallpaper/buildWallpaper.nix index 44eccb4..436d3ac 100644 --- a/home/lib/wallpaper/buildWallpaper.nix +++ b/home/lib/wallpaper/buildWallpaper.nix @@ -41,11 +41,15 @@ let name, path, }: - effect: - if hasAttr effect.name config.lib.wallpapers.effects then - config.lib.wallpapers.effects.${effect.name} { inherit name path; } // effect.passthru + effectName: effectOptions: + if config.lib.wallpapers.effects ? ${effectName} then + config.lib.wallpapers.effects.${effectName} { inherit name path; } // effectOptions else path; + # if hasAttr effect.name config.lib.wallpapers.effects then + # config.lib.wallpapers.effects.${effect.name} { inherit name path; } // effect.passthru + # else + # path; applyEffects = wallpaper: @@ -66,13 +70,15 @@ let { inherit path; } else { - path = foldl' ( - acc: elem: - applyEffect { - inherit name; - path = acc; - } elem - ) path effects; + path = + lib.attrsets.filterAttrs (_: v: v.enable == true) effects + |> lib.attrsets.foldlAttrs ( + acc: effectName: effectOptions: + applyEffect { + inherit name; + path = acc; + } effectName effectOptions + ) path; } ); diff --git a/home/tweaks/wallpaper.nix b/home/tweaks/wallpaper.nix index c0c1075..c556e37 100644 --- a/home/tweaks/wallpaper.nix +++ b/home/tweaks/wallpaper.nix @@ -14,17 +14,15 @@ baseImageName = "frieren-butterflies"; path = "${pkgs.wallpapers}/frieren-butterflies.jpg"; convertMethod = "lutgen"; - effects = [ - { - name = "hydrogen"; - passthru = { + effects = { + hydrogen = { + enable = true; + options = { extraArguments = "--shadow-arguments '80x50+0+0'"; }; - } - { - name = "vignette"; - } - ]; + }; + vignette.enable = true; + }; } { name = "frieren-fire.jpg"; @@ -51,11 +49,7 @@ baseImageName = "bangqiaoyan-girl-sky"; path = "${pkgs.wallpapers}/bangqiaoyan-girl-sky.jpg"; convertMethod = "gonord"; - effects = [ - { - name = "hydrogen"; - } - ]; + effects.hydrogen.enable = true; } { name = "morncolour-pink-landscape.png"; diff --git a/modules/home-manager/wallpaper.nix b/modules/home-manager/wallpaper.nix index 6f7b43f..f93c09e 100644 --- a/modules/home-manager/wallpaper.nix +++ b/modules/home-manager/wallpaper.nix @@ -27,22 +27,18 @@ let }; effects = mkOption { type = nullOr ( - listOf (submodule { + attrsOf (submodule { options = { - name = mkOption { - type = nullOr str; - description = "Name of the effect to apply"; - default = null; - }; - passthru = mkOption { + enable = mkEnableOption "Enable this effect"; + options = mkOption { type = attrs; - description = "Extra arguments to pass to the effect"; + description = "Options for the effect"; default = { }; }; }; }) ); - description = "List of effects to apply to the wallpaper"; + description = "Effects to apply to the wallpaper"; default = null; }; };