aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/UserScripts/WallpaperSelect.sh
diff options
context:
space:
mode:
authorJaKooLit <jimmielovejay@gmail.com>2024-07-11 00:11:00 +0900
committerJaKooLit <jimmielovejay@gmail.com>2024-07-11 00:11:00 +0900
commit3836d2c008c7e0b2a6270ee5132c2a08d10bccc3 (patch)
treee8503aa0cd5b19880e9e066652c8fb305ae38cba /config/hypr/UserScripts/WallpaperSelect.sh
parentd7641d43b3f37ed705ee0630846285b1b1d59506 (diff)
Updated wallpaper Select.sh to handle the wallpapers with spaces or white spaces
Diffstat (limited to 'config/hypr/UserScripts/WallpaperSelect.sh')
-rwxr-xr-xconfig/hypr/UserScripts/WallpaperSelect.sh11
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
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage