diff options
| author | JaKooLit <jimmielovejay@gmail.com> | 2024-07-11 00:11:00 +0900 |
|---|---|---|
| committer | JaKooLit <jimmielovejay@gmail.com> | 2024-07-11 00:11:00 +0900 |
| commit | 3836d2c008c7e0b2a6270ee5132c2a08d10bccc3 (patch) | |
| tree | e8503aa0cd5b19880e9e066652c8fb305ae38cba /config/hypr/UserScripts/WallpaperSelect.sh | |
| parent | d7641d43b3f37ed705ee0630846285b1b1d59506 (diff) | |
Updated wallpaper Select.sh to handle the wallpapers with spaces or white spaces
Diffstat (limited to 'config/hypr/UserScripts/WallpaperSelect.sh')
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperSelect.sh | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/config/hypr/UserScripts/WallpaperSelect.sh b/config/hypr/UserScripts/WallpaperSelect.sh index d2ca7c28..23c02805 100755 --- a/config/hypr/UserScripts/WallpaperSelect.sh +++ b/config/hypr/UserScripts/WallpaperSelect.sh @@ -21,20 +21,23 @@ if pidof swaybg > /dev/null; then pkill swaybg fi -# Retrieve image files -PICS=($(find "${wallDIR}" -type f \( -iname \*.jpg -o -iname \*.jpeg -o -iname \*.png -o -iname \*.gif \))) +# Retrieve image files using null delimiter to handle spaces in filenames +mapfile -d '' PICS < <(find "${wallDIR}" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.gif" \) -print0) + RANDOM_PIC="${PICS[$((RANDOM % ${#PICS[@]}))]}" RANDOM_PIC_NAME=". random" # Rofi command rofi_command="rofi -i -show -dmenu -config ~/.config/rofi/config-wallpaper.rasi" - # Sorting Wallpapers menu() { - sorted_options=($(printf '%s\n' "${PICS[@]}" | sort)) + # Sort the PICS array + IFS=$'\n' sorted_options=($(sort <<<"${PICS[*]}")) + # Place ". random" at the beginning with the random picture as an icon printf "%s\x00icon\x1f%s\n" "$RANDOM_PIC_NAME" "$RANDOM_PIC" + for pic_path in "${sorted_options[@]}"; do pic_name=$(basename "$pic_path") # Displaying .gif to indicate animated images |
