aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/UserScripts/WallpaperSelect.sh
diff options
context:
space:
mode:
authorJa.KooLit <85185940+JaKooLit@users.noreply.github.com>2024-08-08 14:12:23 +0000
committerGitHub <noreply@github.com>2024-08-08 14:12:23 +0000
commitd8a3463934bdc6c89a5bbfdce8b2f2325715c8c9 (patch)
treef8b90bb192c86a619c70b5d6359b4387b1b64bb2 /config/hypr/UserScripts/WallpaperSelect.sh
parent41c4923fe79b1462a54881705a580b730405a370 (diff)
parent66cfe8e38194b6c8fcaf1d74aa31b264c79751bc (diff)
Merge pull request #395 from JaKooLit/development
Development to Main in preparation for Hyprland v0.42.0 recently released
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