diff options
| author | JaKooLit <jimmielovejay@gmail.com> | 2023-11-27 20:10:50 +0900 |
|---|---|---|
| committer | JaKooLit <jimmielovejay@gmail.com> | 2023-11-27 20:10:50 +0900 |
| commit | 72a2ffbc89883244d574fbcb3a3bbb22ea00d0bc (patch) | |
| tree | 247d02bc702db214253564823225be61d3945363 | |
| parent | 273f40cfb3ef2951d914e313eed8887c3eb2b835 (diff) | |
hotfix on wallpaper select
| -rwxr-xr-x | config/hypr/scripts/WallpaperSelect.sh | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/config/hypr/scripts/WallpaperSelect.sh b/config/hypr/scripts/WallpaperSelect.sh index 398fafb1..a3fa1ba0 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 |
