summaryrefslogtreecommitdiff
path: root/walls/mpvpaper.sh
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-04-27 18:29:58 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-04-27 18:29:58 +0800
commitcddeebd21b7e0bee1b8f97d74d9ef74b40abc54b (patch)
treea6396189f7cc9d0156f0a46b1fc13c4943c6f566 /walls/mpvpaper.sh
parent5f52a98caa3a15eff093ec4a7d8f093dd411691c (diff)
walls: organize into one dir
Diffstat (limited to 'walls/mpvpaper.sh')
-rwxr-xr-xwalls/mpvpaper.sh63
1 files changed, 63 insertions, 0 deletions
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