Files
dotfiles/hypr/scripts/random_wallpaper.sh
2025-07-04 00:31:01 +03:00

33 lines
692 B
Bash
Executable File

#!/usr/bin/env bash
WALLPAPER_DIR="$HOME/Pictures/Wallpapers/current/"
DELAY=5m
random_wallpaper() {
# Check if folder is not empty
if [ -z "$(ls -A "$WALLPAPER_DIR")" ]; then
echo "Current wallpaper folder is empty, nothing to do"
exit 0
fi
CURRENT_WALL=$(hyprctl hyprpaper listloaded)
# Get a random wallpaper that is not the current one
WALLPAPER=$(find "$WALLPAPER_DIR" -type l ! -name "$(basename "$CURRENT_WALL")" | shuf -n 1)
# Apply the selected wallpaper
hyprctl hyprpaper unload all
hyprctl hyprpaper reload ,"$WALLPAPER"
echo "Set random wallpaper to $WALLPAPER"
}
loop() {
while true; do
random_wallpaper
sleep "$DELAY"
done
}
loop