From 5b898f56aef6a45bbd77019afc29da4feb7b6872 Mon Sep 17 00:00:00 2001 From: reidlab Date: Tue, 28 Apr 2026 17:58:23 -0700 Subject: [PATCH] backdrop has wallpaper now --- hosts/flubber-machine/default.nix | 1 + hosts/goopnet-interface/default.nix | 1 + modules/desktop/awww.nix | 110 ++++++++++++++++++++++------ modules/desktop/niri.nix | 6 ++ 4 files changed, 97 insertions(+), 21 deletions(-) diff --git a/hosts/flubber-machine/default.nix b/hosts/flubber-machine/default.nix index 5756b29..69765e9 100755 --- a/hosts/flubber-machine/default.nix +++ b/hosts/flubber-machine/default.nix @@ -66,6 +66,7 @@ hyprlock.enable = true; hypridle.enable = true; awww.enable = true; + awww.backdrop = true; gnome-keyring.enable = true; mate-polkit.enable = true; dunst.enable = true; diff --git a/hosts/goopnet-interface/default.nix b/hosts/goopnet-interface/default.nix index 7d4638e..032345f 100755 --- a/hosts/goopnet-interface/default.nix +++ b/hosts/goopnet-interface/default.nix @@ -56,6 +56,7 @@ hyprlock.enable = true; hypridle.enable = true; awww.enable = true; + awww.backdrop = true; gnome-keyring.enable = true; mate-polkit.enable = true; dunst.enable = true; diff --git a/modules/desktop/awww.nix b/modules/desktop/awww.nix index 0745cfd..30f86f5 100644 --- a/modules/desktop/awww.nix +++ b/modules/desktop/awww.nix @@ -6,6 +6,7 @@ let in { options.modules.desktop.awww = { enable = mkEnableOption "Enable awww, an Answer to your Wayland Wallpaper Woes"; + backdrop = mkEnableOption "Enable a second, blurred, awww daemon with a `-backdrop` suffix. Primarily for use in niri"; package = mkOption { type = types.package; default = pkgs.awww; @@ -16,6 +17,11 @@ in { default = "${pkgs.my.wallpapers}/share/backgrounds"; example = "$XDG_PICTURES_DIR/wallpapers"; }; + wallpaperEffectsCacheFolder = mkOption { + type = types.str; + default = "$XDG_CACHE_HOME/wallpaper-blurcache"; + example = "$XDG_CACHE_HOME/wallpaper-blurcache"; + }; lastWallpaper = mkOption { type = types.str; default = "$XDG_DATA_HOME/awww-last-wallpaper"; @@ -26,6 +32,28 @@ in { default = "$XDG_DATA_HOME/awww-last-wallpaper-sym"; example = "$XDG_DATA_HOME/awww-last-wallpaper-sym"; }; + # TODO: somehow make this match up with the theme blur radius when i add that? + blurScript = mkOption { + type = types.package; + default = pkgs.writeShellScript "awww-blur" '' + set -euo pipefail + + : "''${1:?missing argument}" + + mkdir -p "${cfg.wallpaperEffectsCacheFolder}" + blurred="${cfg.wallpaperEffectsCacheFolder}/$(basename "$1")" + + if [ ! -f "$blurred" ]; then + ${lib.getExe pkgs.imagemagick} "$1" \ + -blur 0x8 \ + -fill black \ + -colorize 40% \ + "$blurred" + fi + + echo "$blurred" + ''; + }; setScript = mkOption { type = types.package; default = pkgs.writeShellScript "awww-set" '' @@ -35,8 +63,12 @@ in { echo "$(ls ${cfg.wallpapersFolder} | shuf -n 1)" > "${cfg.lastWallpaper}" fi - ln -sf "${cfg.wallpapersFolder}/$(cat ${cfg.lastWallpaper})" "${cfg.lastWallpaperSym}" # in case the hash of the pkg changes - ${lib.getExe cfg.package} img "${cfg.wallpapersFolder}/$(cat ${cfg.lastWallpaper})" --transition-type none + wallpaper="${cfg.wallpapersFolder}/$(cat ${cfg.lastWallpaper})" + + ln -sf "$wallpaper" "${cfg.lastWallpaperSym}" + + ${lib.getExe cfg.package} img "$wallpaper" --transition-type none + ${lib.optionalString cfg.backdrop ''${lib.getExe cfg.package} img $(${cfg.blurScript} "$wallpaper") --namespace backdrop --transition-type none''} ''; }; swapScript = mkOption { @@ -50,6 +82,7 @@ in { [ ! -f "$wallpaper" ] && exit 1 ${lib.getExe cfg.package} img "$wallpaper" --transition-type grow --transition-fps 60 --transition-pos 1.0,1.0 --transition-duration 1.5 + ${lib.optionalString cfg.backdrop ''${lib.getExe cfg.package} img $(${cfg.blurScript} "$wallpaper") --namespace backdrop --transition-type grow --transition-fps 60 --transition-pos 1.0,1.0 --transition-duration 1.5''} ln -sf "$wallpaper" "${cfg.lastWallpaperSym}" echo "$file" > "${cfg.lastWallpaper}" @@ -57,26 +90,61 @@ in { }; }; - config = mkIf cfg.enable { - hm.home.packages = [ cfg.package ]; - hm.systemd.user.services.awww = { - Unit = { - Description = "awww, an Answer to your Wayland Wallpaper Woes"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; + config = mkMerge [ + (mkIf cfg.enable { + hm.home.packages = [ cfg.package ]; + hm.systemd.user.services.awww = { + Unit = { + Description = "awww, an Answer to your Wayland Wallpaper Woes"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { + WantedBy = [ "graphical-session.target" ]; + }; - Service = { - Type = "simple"; - ExecStart = "${cfg.package}/bin/awww-daemon"; - ExecStartPost = "${cfg.setScript}"; - Restart = "on-failure"; - RestartSec = 5; + Service = { + Type = "simple"; + ExecStart = "${cfg.package}/bin/awww-daemon"; + Restart = "on-failure"; + RestartSec = 5; + }; }; - }; - }; + hm.systemd.user.services.awww-set = { + Unit = { + Description = "awww, an Answer to your Wayland Wallpaper Woes (startup script)"; + After = [ "awww.service" ] ++ optional cfg.backdrop "awww-backdrop.service"; + PartOf = [ "awww.service" ] ++ optional cfg.backdrop "awww-backdrop.service"; + }; + + Service = { + Type = "oneshot"; + ExecStart = "${cfg.setScript}"; + Restart = "on-failure"; + RestartSec = 2; + }; + }; + }) + (mkIf cfg.backdrop { + hm.systemd.user.services.awww-backdrop = { + Unit = { + Description = "awww, an Answer to your Wayland Wallpaper Woes"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + Type = "simple"; + ExecStart = "${cfg.package}/bin/awww-daemon --namespace backdrop"; + Restart = "on-failure"; + RestartSec = 5; + }; + }; + }) + ]; } diff --git a/modules/desktop/niri.nix b/modules/desktop/niri.nix index 411b85e..9533dc9 100644 --- a/modules/desktop/niri.nix +++ b/modules/desktop/niri.nix @@ -311,6 +311,12 @@ in { # TODO: add shadows onto notifications. weird geometry beware !!! layer-rules = [ + { + matches = [ + { namespace = "^.*-?backdrop$"; } + ]; + place-within-backdrop = true; + } { matches = [ { namespace = "^notifications$"; }