From cddeebd21b7e0bee1b8f97d74d9ef74b40abc54b Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 27 Apr 2025 18:29:58 +0800 Subject: walls: organize into one dir --- mpvpaper.sh | 79 ------------------------------------------------- swww.sh | 61 -------------------------------------- wallpapertrans.sh | 40 ------------------------- walls/mpvpaper.sh | 63 +++++++++++++++++++++++++++++++++++++++ walls/swww.sh | 56 +++++++++++++++++++++++++++++++++++ walls/update.sh | 40 +++++++++++++++++++++++++ walls/wallpapertrans.sh | 40 +++++++++++++++++++++++++ 7 files changed, 199 insertions(+), 180 deletions(-) delete mode 100755 mpvpaper.sh delete mode 100755 swww.sh delete mode 100755 wallpapertrans.sh create mode 100755 walls/mpvpaper.sh create mode 100755 walls/swww.sh create mode 100755 walls/update.sh create mode 100755 walls/wallpapertrans.sh diff --git a/mpvpaper.sh b/mpvpaper.sh deleted file mode 100755 index 99acfb7..0000000 --- a/mpvpaper.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash - -renice -n 19 $$ -ionice -c 3 -p $$ - -XDG_VIDEOS_DIR="${XDG_VIDEOS_DIR:-$HOME/Videos}" -XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" -XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" -WALLPAPERS="$XDG_VIDEOS_DIR/wallpapers/" -# swwwarg="--transition-type random --transition-duration 0.85 --transition-fps 160 --transition-bezier 1,0.33,0.3,1" - -# colors -RED='\033[0;31m' -GREEN='\033[0;32m' -NC='\033[0m' - -DELAY=1800 - -while true; do - # (while ! swww query; do swww-daemon; done) & - current_bg="$(cat $XDG_CACHE_HOME/current.bg)" - if ! [ "$current_bg" ]; then - echo -e "${RED}current.bg not set, regenerating it${NC}" - current_bg="$(find "$WALLPAPERS" | shuf -n 1)" - echo "$current_bg" > $XDG_CACHE_HOME/current.bg - echo -e "${GREEN}Regenerating wallpappath${NC}" - fi - wallpappath=$(find "$WALLPAPERS" | shuf -n 1) - - if [ ! -f "$XDG_CACHE_HOME/$(basename "$current_bg").png" ]; then ffmpeg -hwaccel cuda -i "$current_bg" -y "$XDG_CACHE_HOME/$(basename $current_bg).png"; fi - - # wallust run --skip-sequences $current_bg - # wallust run --backend kmeans --skip-sequences $current_bg & # using cache now - # swww img "$XDG_CACHE_HOME/$(basename "$current_bg").png" $swwwarg - # for output in $(hyprctl monitors | grep "Monitor" | awk '{print $2}'); do - # mpvpaper --auto-pause --mpv-options="hwdec=auto --no-audio --loop" --fork "$output" "$current_bg" - - OLD_MPVPAPER_PIDS=$(pidof mpvpaper) - mpvpaper --auto-pause --mpv-options="hwdec=auto --no-audio --loop --mute" --fork "*" "$current_bg" - - # Wait a brief moment to ensure new instance is running - sleep 0.1 - - # Kill old instances if they exist - if [ -n "$OLD_MPVPAPER_PIDS" ]; then - for pid in $OLD_MPVPAPER_PIDS; do - kill $pid 2>/dev/null - done - fi - - # done - - wallust run --backend full --skip-sequences "$XDG_CACHE_HOME/$(basename "$current_bg").png" - - # tell hypr* where is bg - echo "\$bg = $XDG_CACHE_HOME/$(basename "$current_bg").png" > "$XDG_CONFIG_HOME/hypr/bg.conf" - - echo "$XDG_CACHE_HOME/$(basename "$current_bg").png" - - # reload hyprland - hyprctl reload config-only & - - swaync-client --reload-css & # & pywalfox update - - gdbus call --session --dest com.mitchellh.ghostty --object-path /com/mitchellh/ghostty --method org.gtk.Actions.Activate reload-config [] [] & - - # update hyprlock - killall -USR2 hyprlock & - - # next wallpaper - ffmpeg -hwaccel cuda -i "$current_bg" -y "$XDG_CACHE_HOME/bg.png" - current_bg=$(cat "$XDG_CACHE_HOME/current.bg") - echo "$wallpappath" > "$XDG_CACHE_HOME/current.bg" - - # generates cache for next wallpaper - ( ffmpeg -hwaccel cuda -i "$wallpappath" -y "$XDG_CACHE_HOME/$(basename $wallpappath).png"; nice -n 20 wallust run --backend full --skip-templates --skip-sequences "$XDG_CACHE_HOME/$(basename $wallpappath).png" ) & - - nice -n 20 sleep $DELAY -done diff --git a/swww.sh b/swww.sh deleted file mode 100755 index 391d580..0000000 --- a/swww.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -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)" -swwwarg="--transition-type random --transition-duration 0.85 --transition-fps 160 --transition-bezier 1,0.33,0.3,1" - -# colors -RED='\033[0;31m' -GREEN='\033[0;32m' -NC='\033[0m' - -DELAY=1800 - -while true; do - (while ! swww query; do swww-daemon; done) & - 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 - - # wallust run --skip-sequences $(cat $XDG_CACHE_HOME/current.bg) - # wallust run --backend kmeans --skip-sequences $(cat $XDG_CACHE_HOME/current.bg) & # using cache now - swww img $(cat $XDG_CACHE_HOME/current.bg) $swwwarg - wallust run --backend full --skip-sequences $(cat $XDG_CACHE_HOME/current.bg) - # (sleep 0.1; pgrep -f wallust && wallust run --backend kmeans --skip-sequences $(cat $XDG_CACHE_HOME/current.bg)) & - - # tell hypr* where is bg - echo "\$bg = $XDG_CACHE_HOME/$(basename "$current_bg").png" > "$XDG_CONFIG_HOME/hypr/bg.conf" - - # reload hyprland - hyprctl reload config-only & - - swaync-client --reload-css - - gdbus call --session --dest com.mitchellh.ghostty --object-path /com/mitchellh/ghostty --method org.gtk.Actions.Activate reload-config [] [] & - - 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 - # update hyprlock - killall -SIGUSR2 hyprlock - - nice -n 20 wallust run --backend full --skip-templates --skip-sequences $wallpappath - - if swww query; then - sleep $DELAY - else - echo -e "${RED}swww not running, skipping sleep - END${NC}" - swww-daemon & - fi -done diff --git a/wallpapertrans.sh b/wallpapertrans.sh deleted file mode 100755 index 6c87d4a..0000000 --- a/wallpapertrans.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# Animated wallpaper changer -feh --bg-fill $XDG_CACHE_HOME/wallpaper/old.jpg - -DISPLAY=:0 -XDG_PICTURES_DIR="${XDG_PICTURES_DIR:-$HOME/Pictures}" -WALLPAPERS="$XDG_PICTURES_DIR/wallpapers/" -wallpappath=$(find "$WALLPAPERS" | shuf -n 1) -cp "$wallpappath" $XDG_CACHE_HOME/wallpaper/old.jpg -hyprctl hyprpaper preload "$wallpappath" -echo "$wallpappath" > "$XDG_CACHE_HOME/current.bg" - -DELAY=0.005 -QUALITY=0.000001 -RESIZE=30% - - -if [ $# -ne 1 ]; then - for i in {7..11}; do - convert "$wallpappath" -resize $RESIZE -fill black -blur $((75 - ($i - 7) * 15))% -fill black -colorize $((75 - ($i - 7) * 15))% -quality $QUALITY /tmp/transition${i}.jpg & - hyprctl hyprpaper preload "/tmp/transition${i}.jpg" - done - for i in {1..11}; do - # feh --bg-fill /tmp/transition${i}.jpg - hyprctl hyprpaper wallpaper ", /tmp/transition${i}.jpg" - sleep $DELAY - done - rm /tmp/transition*.jpg -fi - -feh --bg-fill "$wallpappath" - -# cp "$wallpappath" $HOME/.cache/wallpaper/old.jpg - -hyprctl hyprpaper unload all - -for i in {1..6}; do - convert $HOME/.cache/wallpaper/old.jpg -resize $RESIZE -fill black -blur $(($i * 10))% -fill black -colorize $(($i * 10))% -quality $QUALITY /tmp/transition${i}.jpg & - hyprctl hyprpaper preload "/tmp/transition${i}.jpg" -done diff --git a/walls/mpvpaper.sh b/walls/mpvpaper.sh new file mode 100755 index 0000000..4d9a490 --- /dev/null +++ b/walls/mpvpaper.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +renice -n 19 $$ +ionice -c 3 -p $$ + +XDG_VIDEOS_DIR="${XDG_VIDEOS_DIR:-$HOME/Videos}" +XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" +XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +WALLPAPERS="$XDG_VIDEOS_DIR/wallpapers/" +# swwwarg="--transition-type random --transition-duration 0.85 --transition-fps 160 --transition-bezier 1,0.33,0.3,1" + +# colors +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' + +DELAY=1800 + +while true; do + # (while ! swww query; do swww-daemon; done) & + current_bg="$(cat $XDG_CACHE_HOME/current.bg)" + if ! [ "$current_bg" ]; then + echo -e "${RED}current.bg not set, regenerating it${NC}" + current_bg="$(find "$WALLPAPERS" | shuf -n 1)" + echo "$current_bg" > $XDG_CACHE_HOME/current.bg + echo -e "${GREEN}Regenerating wallpappath${NC}" + fi + wallpappath=$(find "$WALLPAPERS" | shuf -n 1) + + if [ ! -f "$XDG_CACHE_HOME/$(basename "$current_bg").png" ]; then ffmpeg -hwaccel cuda -i "$current_bg" -y "$XDG_CACHE_HOME/$(basename $current_bg).png"; fi + + # wallust run --skip-sequences $current_bg + # wallust run --backend kmeans --skip-sequences $current_bg & # using cache now + # swww img "$XDG_CACHE_HOME/$(basename "$current_bg").png" $swwwarg + # for output in $(hyprctl monitors | grep "Monitor" | awk '{print $2}'); do + # mpvpaper --auto-pause --mpv-options="hwdec=auto --no-audio --loop" --fork "$output" "$current_bg" + + OLD_MPVPAPER_PIDS=$(pidof mpvpaper) + mpvpaper --auto-pause --mpv-options="hwdec=auto --no-audio --loop --mute" --fork "*" "$current_bg" + + # Wait a brief moment to ensure new instance is running + sleep 0.1 + + # Kill old instances if they exist + if [ -n "$OLD_MPVPAPER_PIDS" ]; then + for pid in $OLD_MPVPAPER_PIDS; do + kill $pid 2>/dev/null + done + fi + + # done + + # Update theme and configurations for current wallpaper + nice -n 20 bash "$(dirname "$0")/update.sh" "$current_bg" + + # Store next wallpaper path + echo "$wallpappath" > "$XDG_CACHE_HOME/current.bg" + + # Generate cache for next wallpaper in background + ( nice -n 20 bash "$(dirname "$0")/update.sh" "$wallpappath" ) & + + nice -n 20 sleep $DELAY +done diff --git a/walls/swww.sh b/walls/swww.sh new file mode 100755 index 0000000..0ba9afc --- /dev/null +++ b/walls/swww.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +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/" +swwwarg="--transition-type random --transition-duration 0.85 --transition-fps 160 --transition-bezier 1,0.33,0.3,1" + +# colors +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' + +DELAY=1800 + +while true; do + (while ! swww query; do swww-daemon; done) & + 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 + current_bg="$(cat $XDG_CACHE_HOME/current.bg)" + + # wallust run --skip-sequences $(cat $XDG_CACHE_HOME/current.bg) + # wallust run --backend kmeans --skip-sequences $(cat $XDG_CACHE_HOME/current.bg) & # using cache now + swww img $current_bg $swwwarg + wallust run --backend full --skip-sequences $(cat $XDG_CACHE_HOME/current.bg) & + # (sleep 0.1; pgrep -f wallust && wallust run --backend kmeans --skip-sequences $(cat $XDG_CACHE_HOME/current.bg)) & + + # tell hypr* where is bg + echo "\$bg = $current_bg" > "$XDG_CONFIG_HOME/hypr/bg.conf" + + # reload hyprland + hyprctl reload config-only & + + swaync-client --reload-css + + gdbus call --session --dest com.mitchellh.ghostty --object-path /com/mitchellh/ghostty --method org.gtk.Actions.Activate reload-config [] [] & + + current_bg=$(cat $XDG_CACHE_HOME/current.bg) + echo $wallpappath > $XDG_CACHE_HOME/current.bg + # update hyprlock + killall -SIGUSR2 hyprlock + + nice -n 20 wallust run --backend full --skip-templates --skip-sequences $wallpappath + + if swww query; then + sleep $DELAY + else + echo -e "${RED}swww not running, skipping sleep - END${NC}" + swww-daemon & + fi +done diff --git a/walls/update.sh b/walls/update.sh new file mode 100755 index 0000000..e2d9bbe --- /dev/null +++ b/walls/update.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# ARG1 = wallpaper path + +XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" +XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" + +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' + +if [ -z "$1" ]; then + echo -e "${RED}Error: No wallpaper path provided${NC}" + exit 1 +fi + +WALLPAPER="$1" + +if [ ! -f "$XDG_CACHE_HOME/$(basename "$WALLPAPER").png" ]; then + echo -e "${GREEN}Generating PNG cache for $WALLPAPER${NC}" + ffmpeg -hwaccel cuda -i "$WALLPAPER" -y "$XDG_CACHE_HOME/$(basename "$WALLPAPER").png" +fi + +wallust run --backend full --skip-sequences "$XDG_CACHE_HOME/$(basename "$WALLPAPER").png" + +echo "\$bg = $XDG_CACHE_HOME/$(basename "$WALLPAPER").png" > "$XDG_CONFIG_HOME/hypr/bg.conf" + +ffmpeg -hwaccel cuda -i "$WALLPAPER" -y "$XDG_CACHE_HOME/bg.png" + +( + hyprctl reload config-only & + + swaync-client --reload-css & + + gdbus call --session --dest com.mitchellh.ghostty --object-path /com/mitchellh/ghostty --method org.gtk.Actions.Activate reload-config [] [] & + + killall -USR2 hyprlock & +) & + +echo "$WALLPAPER" > "$XDG_CACHE_HOME/current.bg" diff --git a/walls/wallpapertrans.sh b/walls/wallpapertrans.sh new file mode 100755 index 0000000..6c87d4a --- /dev/null +++ b/walls/wallpapertrans.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Animated wallpaper changer +feh --bg-fill $XDG_CACHE_HOME/wallpaper/old.jpg + +DISPLAY=:0 +XDG_PICTURES_DIR="${XDG_PICTURES_DIR:-$HOME/Pictures}" +WALLPAPERS="$XDG_PICTURES_DIR/wallpapers/" +wallpappath=$(find "$WALLPAPERS" | shuf -n 1) +cp "$wallpappath" $XDG_CACHE_HOME/wallpaper/old.jpg +hyprctl hyprpaper preload "$wallpappath" +echo "$wallpappath" > "$XDG_CACHE_HOME/current.bg" + +DELAY=0.005 +QUALITY=0.000001 +RESIZE=30% + + +if [ $# -ne 1 ]; then + for i in {7..11}; do + convert "$wallpappath" -resize $RESIZE -fill black -blur $((75 - ($i - 7) * 15))% -fill black -colorize $((75 - ($i - 7) * 15))% -quality $QUALITY /tmp/transition${i}.jpg & + hyprctl hyprpaper preload "/tmp/transition${i}.jpg" + done + for i in {1..11}; do + # feh --bg-fill /tmp/transition${i}.jpg + hyprctl hyprpaper wallpaper ", /tmp/transition${i}.jpg" + sleep $DELAY + done + rm /tmp/transition*.jpg +fi + +feh --bg-fill "$wallpappath" + +# cp "$wallpappath" $HOME/.cache/wallpaper/old.jpg + +hyprctl hyprpaper unload all + +for i in {1..6}; do + convert $HOME/.cache/wallpaper/old.jpg -resize $RESIZE -fill black -blur $(($i * 10))% -fill black -colorize $(($i * 10))% -quality $QUALITY /tmp/transition${i}.jpg & + hyprctl hyprpaper preload "/tmp/transition${i}.jpg" +done -- cgit v1.2.3