random-wallpaper: Additional check

Exit the script if no wallpapers could be find. This should prevent
creating empty symbolic link to .current-wallpaper
This commit is contained in:
Harzo 2023-05-30 23:11:13 +02:00
parent cc833e6c5b
commit fba9579488
1 changed files with 4 additions and 0 deletions

View File

@ -11,6 +11,10 @@ interval_secs="$(echo "60 * ${INTERVAL}" | bc)"
while true; do while true; do
wallpaper="$(fd '\.(png|jpe?g|gif)$' "$WALLPAPER_DIR" --type f --type l -L | shuf | head -1)" wallpaper="$(fd '\.(png|jpe?g|gif)$' "$WALLPAPER_DIR" --type f --type l -L | shuf | head -1)"
if [ -z "$wallpaper" ]; then
echo "Couldn't find any wallpapers. Abort" >&2
exit 1
fi
ln -sf "$wallpaper" "/run/user/$(id -u)/.current-wallpaper" ln -sf "$wallpaper" "/run/user/$(id -u)/.current-wallpaper"
swww img "$wallpaper" swww img "$wallpaper"
sleep "$interval_secs" sleep "$interval_secs"