swaydots

my dotfiles
git clone https://git.awy.one/swaydots.git
Log | Files | Refs | README | LICENSE

randombg (613B)


      1 #!/bin/sh
      2 killall swaybg
      3 PIDFILE="/tmp/randombg.pid"
      4 # Check if the PID file exists and if the process is running
      5 if [ -e "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")"; then
      6     echo "Another instance of the script is already running."
      7     kill -9 "$(cat $PIDFILE)"  # Forcefully kill the old process
      8 fi
      9 echo $$ > "$PIDFILE"
     10 trap 'rm -f "$PIDFILE"; exit' INT TERM EXIT
     11 
     12 swaybg -i $(find /mnt/ssd/papes/. -type f | shuf -n1) -m fill &
     13 OLD_PID=$!
     14 while true; do
     15     sleep 300
     16     swaybg -i $(find /mnt/ssd/papes/. -type f | shuf -n1) -m fill &
     17     NEXT_PID=$!
     18     sleep 5
     19     kill $OLD_PID
     20     OLD_PID=$NEXT_PID
     21 done