diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2024-09-17 18:37:48 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2024-09-17 18:37:48 +0800 |
| commit | 7e4cc69ce781fa5fc84f8004ee347a8efff3432f (patch) | |
| tree | e06faa625469eae9006b9c86a2274a66ece016d1 | |
| parent | a0ec345229e272af847b7c12213dab5f6829dfab (diff) | |
improvements for hyprpaper, idle
| -rwxr-xr-x | hypridle.sh | 2 | ||||
| -rwxr-xr-x | hyprpaper.sh | 46 |
2 files changed, 37 insertions, 11 deletions
diff --git a/hypridle.sh b/hypridle.sh index d42d4f5..f903cad 100755 --- a/hypridle.sh +++ b/hypridle.sh @@ -37,6 +37,7 @@ function idle() { if [ $pmusic ]; then playerctl --all-players pause fi + killall -STOP hyprpaper.sh brillio -O brillio -S 0 } @@ -63,6 +64,7 @@ function stopidle() { playerctl play -p spotify unset m fi + killall -CONT hyprpaper.sh || $HOME/scripts/hyprpaper.sh & rm -f $XDG_CACHE_HOME/playing-music brillio -I } diff --git a/hyprpaper.sh b/hyprpaper.sh index b8e2999..5091d66 100755 --- a/hyprpaper.sh +++ b/hyprpaper.sh @@ -4,29 +4,53 @@ XDG_PICTURES_DIR="${XDG_PICTURES_DIR:-$HOME/Pictures}" XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" WALLPAPERS="$XDG_PICTURES_DIR/wallpapers/" +current_bg="$(cat $XDG_CACHE_HOME/current.bg)" -DELAY=1800 +# colors +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' -while ! hyprctl hyprpaper; do - sleep 0.05 -done +DELAY=1800 while true; do + if ! hyprctl hyprpaper; then + echo -e "${RED}hyprpaper not running, launching it... - BEGIN${NC}" + hyprpaper & + fi wallpappath=$(find "$WALLPAPERS" | shuf -n 1) + if ! [ $current_bg ]; then + echo -e "${RED}current.bg not set, setting it to $wallpappath${NC}" + echo $wallpappath > $XDG_CACHE_HOME/current.bg + echo -e "${GREEN}Regenerating wallpappath${NC}" + wallpappath=$(find "$WALLPAPERS" | shuf -n 1) + fi + # make it wallpaper the already preloaded one and preload for next time # hyprctl hyprpaper wallpaper ", $(hyprctl hyprpaper listloaded)" # hyprctl hyprpaper unload $(hyprctl hyprpaper listloaded) # hyprctl hyprpaper preload $wallpappath - - hyprctl hyprpaper unload $(hyprctl hyprpaper listloaded) || hyprctl hyprpaper unload all + while ! hyprctl hyprpaper wallpaper ", $(cat $XDG_CACHE_HOME/current.bg)"; do hyprctl hyprpaper preload $(cat $XDG_CACHE_HOME/current.bg); done + # update hyprlock + killall -SIGUSR2 hyprlock + hyprctl hyprpaper unload $(cat $XDG_CACHE_HOME/current.bg) || hyprctl hyprpaper unload all hyprctl hyprpaper preload $wallpappath - hyprctl hyprpaper wallpaper ", $wallpappath" + current_bg=$(cat $XDG_CACHE_HOME/current.bg) + if [[ $current_bg == *.jpg ]]; then + magick convert $current_bg $XDG_CACHE_HOME/bg.png & + else + cp $current_bg $XDG_CACHE_HOME/bg.png + fi + echo $wallpappath > $XDG_CACHE_HOME/current.bg + + # hyprctl hyprpaper unload $(hyprctl hyprpaper listloaded) || hyprctl hyprpaper unload all + # hyprctl hyprpaper preload $wallpappath + # hyprctl hyprpaper wallpaper ", $wallpappath" # for hyprlock sake - if [[ $wallpappath == *.jpg ]]; then - convert $wallpappath $XDG_CACHE_HOME/cwall.png + if hyprctl hyprpaper; then + sleep $DELAY else - cp $wallpappath $XDG_CACHE_HOME/cwall.png + echo -e "${RED}hyprpaper not running, skipping sleep - END${NC}" fi - sleep $DELAY done |
