From 6a384db287515c643847cc5d743393e955a31636 Mon Sep 17 00:00:00 2001 From: Amy Retzerau Date: Sat, 10 Jan 2026 15:42:26 +0100 Subject: [PATCH] feat: adapted to new hyprctl IPC that removed loaded grrrrr --- .config/systemd/user/wallpaper.service | 6 ++- .config/systemd/user/wallpaper.timer | 2 +- wallpaper/script.sh | 56 +++++++++++++++----------- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/.config/systemd/user/wallpaper.service b/.config/systemd/user/wallpaper.service index 203ee50..249d8ca 100644 --- a/.config/systemd/user/wallpaper.service +++ b/.config/systemd/user/wallpaper.service @@ -1,7 +1,11 @@ [Unit] Description=Time based wallpaper switcher +#Requires=hyprpaper.service +#After=hyprpaper.service + +PartOf=graphical-session.target +After=graphical-session.target hyprpaper.service Requires=hyprpaper.service -After=graphical-session.target [Service] Type=simple diff --git a/.config/systemd/user/wallpaper.timer b/.config/systemd/user/wallpaper.timer index bb392ad..824b14c 100644 --- a/.config/systemd/user/wallpaper.timer +++ b/.config/systemd/user/wallpaper.timer @@ -1,6 +1,6 @@ [Unit] Description=Run foo weekly and on boot -Requires=graphical-session.target +Requires=graphical-session.target,hyprpaper.service [Timer] OnCalendar=hourly diff --git a/wallpaper/script.sh b/wallpaper/script.sh index 77e1173..03467bf 100755 --- a/wallpaper/script.sh +++ b/wallpaper/script.sh @@ -1,31 +1,39 @@ #!/bin/bash -pidof hyprpaper || hyprctl dispatch exec hyprpaper PATHNAME=~/wallpaper/ cd $PATHNAME -printf -v date "%(%H)T" +date=`date +"%H"` -until pid=$(hyprctl hyprpaper listloaded) -do - sleep 1 -done +FOUND=-24 -LAST=-1 -FOUND=-1 -for filename in $(ls *.{jpg,JPG,png,PNG} | sort -g) -do - if ((${filename%%.*} > date && ${FOUND%%.*} == -1));then - #echo ${FOUND%%.*} - FOUND=$LAST - if ((${FOUND%%.*}==-1));then - FOUND=-2 - fi - fi - LAST=$filename -done - -if ((${FOUND%%.*} < 0));then - FOUND=$LAST +if [[ -f "last.txt" ]]; then + source "last.txt" +else + LAST_WALLPAPER=-1 fi -hyprctl hyprpaper wallpaper ",$PATHNAME$FOUND" -echo ${FOUND%%.*} +until hyprctl -j monitors | grep -q " " +do + sleep 0.1 +done + +for filename in $(ls *.{jpg,JPG,png,PNG} | sort -g) +do + if (( ${filename%%.*} -date<=0 && ${filename%%.*} -date > ${FOUND%%.*} -date));then + FOUND=$filename + # if ((${FOUND%%.*}==-1));then + # FOUND=-2 + # fi + fi + # LAST=$filename +done + +echo $FOUND + +sleep 1 + +if [[ "$LAST_WALLPAPER" != "$FOUND" || "$( hyprctl layers | grep hyprpaper )" == "" ]] ;then + echo "change to $FOUND" + hyprctl hyprpaper wallpaper ",$FOUND" +fi + +echo "LAST_WALLPAPER=$FOUND" > last.txt