dotfiles/.local/bin/scripts/system/random-wallpaper

22 lines
482 B
Plaintext
Raw Permalink Normal View History

2023-05-26 13:29:25 +02:00
#!/bin/sh
INTERVAL="$1"
WALLPAPER_DIR="$2"
rm -rf ~/.cache/swww/
swww kill
swww init
interval_secs="$(echo "60 * ${INTERVAL}" | bc)"
while true; do
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"
2023-05-26 13:29:25 +02:00
swww img "$wallpaper"
sleep "$interval_secs"
done