dwm/dwm_random_bg.sh

20 lines
587 B
Bash
Executable File

#!/bin/bash
# Directory containing wallpapers
WALLPAPER_DIR="$HOME/.config/suckless_desktop/wallpaper/allowed"
# Find all .png, .jpg, and .jpwg files (case-insensitive)
files=( $(find -L "$WALLPAPER_DIR" -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpwg" \)) )
# 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"