change the wallpaper-changer script to use a pid file
This commit is contained in:
parent
1cb4b45de1
commit
c1ef7c8ef8
@ -1,6 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
Wallpaper_DIR="/home/smayzy/wallpaper"
|
||||
LOCKFILE="/tmp/wallpaper_changer.lock"
|
||||
|
||||
if [ -f "$LOCKFILE" ]; then
|
||||
old_pid=$(cat "$LOCKFILE")
|
||||
if ps -p "$old_pid" > /dev/null 2>&1; then
|
||||
kill "$old_pid"
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo $$ > "$LOCKFILE"
|
||||
|
||||
set_wallpaper() {
|
||||
local Wallpaper=$(find $Wallpaper_DIR | shuf -n 1)
|
||||
@ -10,11 +21,12 @@ set_wallpaper() {
|
||||
echo "preload = $Wallpaper" >> /home/smayzy/.config/hypr/hyprpaper.conf
|
||||
echo "wallpaper = ,$Wallpaper" >> /home/smayzy/.config/hypr/hyprpaper.conf
|
||||
|
||||
# Restart hyprpaper
|
||||
pkill hyprpaper 2>/dev/null
|
||||
hyprpaper &
|
||||
}
|
||||
|
||||
trap "rm -f $LOCKFILE" EXIT
|
||||
|
||||
while true; do
|
||||
set_wallpaper
|
||||
sleep 600
|
||||
|
||||
Loading…
Reference in New Issue
Block a user