modify wallpaper.sh to stop it from letting multiple instances run at the same time
This commit is contained in:
parent
e83ff7f66a
commit
dbcbce2a62
@ -1,17 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
Wallpaper_DIR="/home/smayzy/wallpaper"
|
||||
LOCKFILE="/tmp/wallpaper_changer.lock"
|
||||
MONITOR=$(hyprctl monitors | awk '/Monitor/ {print $2; exit}')
|
||||
|
||||
if [ -f "$LOCKFILE" ]; then
|
||||
old_pid=$(cat "$LOCKFILE")
|
||||
if ps -p "$old_pid" > /dev/null 2>&1; then
|
||||
kill "$old_pid"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo $$ > "$LOCKFILE"
|
||||
SCRIPT_NAME=$(basename "$0")
|
||||
SELF_PID=$$
|
||||
pgrep -f "$SCRIPT_NAME" | grep -v "^$SELF_PID$" | while read -r pid; do
|
||||
kill "$pid"
|
||||
done
|
||||
|
||||
set_wallpaper() {
|
||||
local Wallpaper=$(find $Wallpaper_DIR | shuf -n 1)
|
||||
@ -25,8 +21,6 @@ set_wallpaper() {
|
||||
hyprpaper &
|
||||
}
|
||||
|
||||
trap "rm -f $LOCKFILE" EXIT
|
||||
|
||||
while true; do
|
||||
set_wallpaper
|
||||
sleep 600
|
||||
|
||||
Loading…
Reference in New Issue
Block a user