From 72a2ffbc89883244d574fbcb3a3bbb22ea00d0bc Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Mon, 27 Nov 2023 20:10:50 +0900 Subject: [PATCH] hotfix on wallpaper select --- config/hypr/scripts/WallpaperSelect.sh | 30 +++++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/config/hypr/scripts/WallpaperSelect.sh b/config/hypr/scripts/WallpaperSelect.sh index 398fafb..a3fa1ba 100755 --- a/config/hypr/scripts/WallpaperSelect.sh +++ b/config/hypr/scripts/WallpaperSelect.sh @@ -3,7 +3,7 @@ SCRIPTSDIR="$HOME/.config/hypr/scripts" # WALLPAPERS PATH -DIR="$HOME/Pictures/wallpapers/" +DIR="$HOME/Pictures/wallpapers" # Transition config FPS=30 @@ -28,14 +28,13 @@ menu() { for i in "${!PICS[@]}"; do # Displaying .gif to indicate animated images if [[ -z $(echo "${PICS[$i]}" | grep .gif$) ]]; then - filename=$(basename "${PICS[$i]}" | sed 's/\.[^.]*$//') # Remove file extension - printf "%s\n" "${filename//[[:digit:]]/}" # Remove leading numbers + printf "$(echo "${PICS[$i]}" | cut -d. -f1)\n" else - printf "%s\n" "${PICS[$i]}" + printf "${PICS[$i]}\n" fi done - printf "%s\n" "$RANDOM_PIC_NAME" + printf "$RANDOM_PIC_NAME\n" } swww query || swww init @@ -54,8 +53,22 @@ main() { exit 0 fi - pic_index=$(printf '%s\n' "${!PICS[@]}" | grep -E "\b${choice}\b") # Get index based on choice - swww img "${DIR}/${PICS[$pic_index]}" $SWWW_PARAMS + # Find the index of the selected file + pic_index=-1 + for i in "${!PICS[@]}"; do + filename=$(basename "${PICS[$i]}") + if [[ "$filename" == "$choice"* ]]; then + pic_index=$i + break + fi + done + + if [[ $pic_index -ne -1 ]]; then + swww img "${DIR}/${PICS[$pic_index]}" $SWWW_PARAMS + else + echo "Image not found." + exit 1 + fi } # Check if rofi is already running @@ -67,4 +80,5 @@ fi main ${SCRIPTSDIR}/PywalSwww.sh & -${SCRIPTSDIR}/Refresh.sh +sleep 1 +${SCRIPTSDIR}/Refresh.sh