From c746f33c748ae1652c9bbcfd07f073e32a9c828e Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Sun, 15 Oct 2023 22:27:32 +0530 Subject: [PATCH] exit when the response has no images --- packages/scripts/wallhaven.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/scripts/wallhaven.sh b/packages/scripts/wallhaven.sh index 9f8820d..5f2ecb8 100755 --- a/packages/scripts/wallhaven.sh +++ b/packages/scripts/wallhaven.sh @@ -72,6 +72,10 @@ URL="${WALLHAVEN_BASE_URL}/search?${TAGS}${CATEGORIES}${PURITY}${SIZE}${RATIOS}$ CURL_CMD="${CURL_BASE_CMD} \"${URL}\"" RESULT="$(eval ${CURL_CMD})" NO_OF_IMAGES="$(printf "${RESULT}" | jq -r '.meta.total')" +if [ "${NO_OF_IMAGES}" -eq 0 ]; then + notify-send -u normal -a Wallpapers -i information -t 5000 "Wallpapers" "No images available for current configuration." + exit 1 +fi RANDOM_ITEM="$(shuf -i 0-$((NO_OF_IMAGES-1)) -n 1 --random-source=/dev/urandom)" ITEM_PAGE=$((RANDOM_ITEM/24)) ITEM_NUMBER=$((RANDOM_ITEM%24))