From 77007dab23a0fd2abc59d6e34bfb324f5335eb1b Mon Sep 17 00:00:00 2001 From: EdenQwQ Date: Mon, 6 Oct 2025 17:17:28 +0800 Subject: [PATCH] better wallpaper restoring --- home/programs/desktop/niri/autostart.nix | 16 +++++++++++++--- home/programs/desktop/scripts/change-wal-niri | 3 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/home/programs/desktop/niri/autostart.nix b/home/programs/desktop/niri/autostart.nix index cb06177..b96c0eb 100644 --- a/home/programs/desktop/niri/autostart.nix +++ b/home/programs/desktop/niri/autostart.nix @@ -29,16 +29,26 @@ let swww kill swww-daemon --namespace "background" & swww-daemon --namespace "backdrop" & - swww restore --namespace "background" - swww restore --namespace "backdrop" + # swww restore --namespace "background" + # swww restore --namespace "backdrop" clash-meta -d ~/.config/clash & wlsunset -s 00:00 -S 00:00 -t 5000 -T 5001 & '' + + ( + builtins.attrNames config.monitors + |> map (monitor: [ + "swww img --namespace background -o ${monitor} \"/home/${user}/Pictures/Wallpapers/generated/$(cat ~/.cache/swww/${monitor}-file)\"" + "swww img --namespace backdrop -o ${monitor} \"/home/${user}/Pictures/Wallpapers/generated/$(cat ~/.cache/swww/${monitor}-blurred-file)\"" + ]) + |> builtins.concatLists + |> builtins.concatStringsSep "\n" + ) + + "\n" + ( if config.desktopShell == "caelestia" then # bash '' - caelestia wallpaper -f "$HOME/Pictures/Wallpapers/generated/$(cat ~/.cache/swww/${config.lib.monitors.mainMonitorName}-file)" + caelestia wallpaper -f "/home/${user}/Pictures/Wallpapers/generated/$(cat ~/.cache/swww/${config.lib.monitors.mainMonitorName}-file)" caelestia scheme set -n dynamic -m dark '' else diff --git a/home/programs/desktop/scripts/change-wal-niri b/home/programs/desktop/scripts/change-wal-niri index 41d5e9c..807f7d9 100755 --- a/home/programs/desktop/scripts/change-wal-niri +++ b/home/programs/desktop/scripts/change-wal-niri @@ -3,10 +3,11 @@ wallpapers_dir="$HOME/Pictures/Wallpapers/generated" wall=$(ls $wallpapers_dir | grep -v '\-blurred\.jpg$' | tofi) if [ -z $wall ]; then - exit + exit 1 fi output=$(niri msg -j focused-output | jq -r .name) swww img -o $output $wallpapers_dir/$wall --transition-type random --transition-duration 1 --namespace background blurwall=$(echo $wall | sed 's/\.jpg$/-blurred.jpg/') swww img -o $output $wallpapers_dir/$blurwall --transition-type fade --namespace backdrop echo $wall > $HOME/.cache/swww/"$output"-file +echo $blurwall > $HOME/.cache/swww/"$output"-blurred-file