diff options
author | awy <awy@awy.one> | 2025-07-29 03:42:18 +0300 |
---|---|---|
committer | awy <awy@awy.one> | 2025-07-29 03:42:18 +0300 |
commit | ef6dff4cce15186a66ba34cdd7bd39958ebf7f58 (patch) | |
tree | fcfa61164ca6e79c900b5d11f6afc6b46aaccb84 /.local/bin/randombg | |
download | hyprdots-ef6dff4cce15186a66ba34cdd7bd39958ebf7f58.tar.gz |
first commit
Diffstat (limited to '.local/bin/randombg')
-rwxr-xr-x | .local/bin/randombg | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/.local/bin/randombg b/.local/bin/randombg new file mode 100755 index 0000000..6e386ef --- /dev/null +++ b/.local/bin/randombg @@ -0,0 +1,21 @@ +#!/bin/sh +killall swaybg +PIDFILE="/tmp/randombg.pid" +# Check if the PID file exists and if the process is running +if [ -e "$PIDFILE" ] && kill -0 "$(bat "$PIDFILE")"; then + echo "Another instance of the script is already running." + kill -9 "$(bat $PIDFILE)" # Forcefully kill the old process +fi +echo $$ > "$PIDFILE" +trap 'rm -f "$PIDFILE"; exit' INT TERM EXIT + +swaybg -i $(fd . /mnt/ssd/papes -t f | shuf -n1) -m fill & +OLD_PID=$! +while true; do + sleep 300 + swaybg -i $(fd . /mnt/ssd/papes -t f | shuf -n1) -m fill & + NEXT_PID=$! + sleep 5 + kill $OLD_PID + OLD_PID=$NEXT_PID +done |