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

@ -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;
};
};
})
];
}

View file

@ -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$"; }