exit when the response has no images

This commit is contained in:
Adithya 2023-10-15 22:27:32 +05:30
parent 9b756835a2
commit c746f33c74
Signed by: adtya
GPG key ID: 48FC9915FFD326D0

View file

@ -72,6 +72,10 @@ URL="${WALLHAVEN_BASE_URL}/search?${TAGS}${CATEGORIES}${PURITY}${SIZE}${RATIOS}$
CURL_CMD="${CURL_BASE_CMD} \"${URL}\"" CURL_CMD="${CURL_BASE_CMD} \"${URL}\""
RESULT="$(eval ${CURL_CMD})" RESULT="$(eval ${CURL_CMD})"
NO_OF_IMAGES="$(printf "${RESULT}" | jq -r '.meta.total')" 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)" RANDOM_ITEM="$(shuf -i 0-$((NO_OF_IMAGES-1)) -n 1 --random-source=/dev/urandom)"
ITEM_PAGE=$((RANDOM_ITEM/24)) ITEM_PAGE=$((RANDOM_ITEM/24))
ITEM_NUMBER=$((RANDOM_ITEM%24)) ITEM_NUMBER=$((RANDOM_ITEM%24))