backdrop has wallpaper now

This commit is contained in:
Reid 2026-04-28 17:58:23 -07:00
parent 97110919cd
commit 5b898f56ae
Signed by: reidlab
GPG key ID: DAF5EAF6665839FD
4 changed files with 97 additions and 21 deletions

View file

@ -66,6 +66,7 @@
hyprlock.enable = true; hyprlock.enable = true;
hypridle.enable = true; hypridle.enable = true;
awww.enable = true; awww.enable = true;
awww.backdrop = true;
gnome-keyring.enable = true; gnome-keyring.enable = true;
mate-polkit.enable = true; mate-polkit.enable = true;
dunst.enable = true; dunst.enable = true;

View file

@ -56,6 +56,7 @@
hyprlock.enable = true; hyprlock.enable = true;
hypridle.enable = true; hypridle.enable = true;
awww.enable = true; awww.enable = true;
awww.backdrop = true;
gnome-keyring.enable = true; gnome-keyring.enable = true;
mate-polkit.enable = true; mate-polkit.enable = true;
dunst.enable = true; dunst.enable = true;

View file

@ -6,6 +6,7 @@ let
in { in {
options.modules.desktop.awww = { options.modules.desktop.awww = {
enable = mkEnableOption "Enable awww, an Answer to your Wayland Wallpaper Woes"; 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 { package = mkOption {
type = types.package; type = types.package;
default = pkgs.awww; default = pkgs.awww;
@ -16,6 +17,11 @@ in {
default = "${pkgs.my.wallpapers}/share/backgrounds"; default = "${pkgs.my.wallpapers}/share/backgrounds";
example = "$XDG_PICTURES_DIR/wallpapers"; example = "$XDG_PICTURES_DIR/wallpapers";
}; };
wallpaperEffectsCacheFolder = mkOption {
type = types.str;
default = "$XDG_CACHE_HOME/wallpaper-blurcache";
example = "$XDG_CACHE_HOME/wallpaper-blurcache";
};
lastWallpaper = mkOption { lastWallpaper = mkOption {
type = types.str; type = types.str;
default = "$XDG_DATA_HOME/awww-last-wallpaper"; default = "$XDG_DATA_HOME/awww-last-wallpaper";
@ -26,6 +32,28 @@ in {
default = "$XDG_DATA_HOME/awww-last-wallpaper-sym"; default = "$XDG_DATA_HOME/awww-last-wallpaper-sym";
example = "$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 { setScript = mkOption {
type = types.package; type = types.package;
default = pkgs.writeShellScript "awww-set" '' default = pkgs.writeShellScript "awww-set" ''
@ -35,8 +63,12 @@ in {
echo "$(ls ${cfg.wallpapersFolder} | shuf -n 1)" > "${cfg.lastWallpaper}" echo "$(ls ${cfg.wallpapersFolder} | shuf -n 1)" > "${cfg.lastWallpaper}"
fi fi
ln -sf "${cfg.wallpapersFolder}/$(cat ${cfg.lastWallpaper})" "${cfg.lastWallpaperSym}" # in case the hash of the pkg changes wallpaper="${cfg.wallpapersFolder}/$(cat ${cfg.lastWallpaper})"
${lib.getExe cfg.package} img "${cfg.wallpapersFolder}/$(cat ${cfg.lastWallpaper})" --transition-type none
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 { swapScript = mkOption {
@ -50,6 +82,7 @@ in {
[ ! -f "$wallpaper" ] && exit 1 [ ! -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.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}" ln -sf "$wallpaper" "${cfg.lastWallpaperSym}"
echo "$file" > "${cfg.lastWallpaper}" echo "$file" > "${cfg.lastWallpaper}"
@ -57,26 +90,61 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = mkMerge [
hm.home.packages = [ cfg.package ]; (mkIf cfg.enable {
hm.systemd.user.services.awww = { hm.home.packages = [ cfg.package ];
Unit = { hm.systemd.user.services.awww = {
Description = "awww, an Answer to your Wayland Wallpaper Woes"; Unit = {
After = [ "graphical-session-pre.target" ]; Description = "awww, an Answer to your Wayland Wallpaper Woes";
PartOf = [ "graphical-session.target" ]; After = [ "graphical-session-pre.target" ];
}; PartOf = [ "graphical-session.target" ];
};
Install = { Install = {
WantedBy = [ "graphical-session.target" ]; WantedBy = [ "graphical-session.target" ];
}; };
Service = { Service = {
Type = "simple"; Type = "simple";
ExecStart = "${cfg.package}/bin/awww-daemon"; ExecStart = "${cfg.package}/bin/awww-daemon";
ExecStartPost = "${cfg.setScript}"; Restart = "on-failure";
Restart = "on-failure"; RestartSec = 5;
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;
};
};
})
];
} }

View file

@ -311,6 +311,12 @@ in {
# TODO: add shadows onto notifications. weird geometry beware !!! # TODO: add shadows onto notifications. weird geometry beware !!!
layer-rules = [ layer-rules = [
{
matches = [
{ namespace = "^.*-?backdrop$"; }
];
place-within-backdrop = true;
}
{ {
matches = [ matches = [
{ namespace = "^notifications$"; } { namespace = "^notifications$"; }