dwm/dwm_random_bg.sh

20 lines
587 B
Bash
Raw Normal View History

2025-03-04 11:55:33 +00:00
#!/bin/bash
# Directory containing wallpapers
2025-04-01 13:57:50 +00:00
WALLPAPER_DIR="$HOME/.config/suckless_desktop/wallpaper/allowed"
2025-03-04 11:55:33 +00:00
# Find all .png, .jpg, and .jpwg files (case-insensitive)
2025-04-01 13:57:50 +00:00
files=( $(find -L "$WALLPAPER_DIR" -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpwg" \)) )
2025-03-04 11:55:33 +00:00
# Check if we found any wallpapers
if [ ${#files[@]} -eq 0 ]; then
echo "No wallpaper files found in $WALLPAPER_DIR."
exit 1
fi
# Choose a random file from the array
RANDOM_FILE="${files[RANDOM % ${#files[@]}]}"
# Set the chosen file as the wallpaper using xwallpaper
xwallpaper --zoom "$RANDOM_FILE"