single notification for wallpaper changes

This commit is contained in:
Adithya 2024-01-04 21:51:22 +05:30
parent df80976410
commit 8981800f71
Signed by: adtya
GPG key ID: 48FC9915FFD326D0
2 changed files with 6 additions and 6 deletions

View file

@ -20,4 +20,4 @@ swww query || swww init
convert "$(random_paper)" /tmp/wallpaper.jpg && swww img --transition-step 2 --transition-type random --transition-duration 1 "/tmp/wallpaper.jpg"
convert "$(random_paper)" /tmp/lockpaper.jpg
notify-send -r 9897 -i information -t 1000 "Wallpaper" "Wallpaper changed."
notify-send -r 1234 -i information -t 5000 "Wallpaper" "Wallpaper changed."

View file

@ -67,13 +67,13 @@ if [ -n "${RANGE}" ]; then
RANGE="topRange=${RANGE}&"
fi
notify-send -u normal -a Wallpapers -i information -t 5000 "Wallpapers" "Fetching a list of wallpapers..."
notify-send -r 1234 -u normal -a Wallpapers -i information -t 5000 "Wallpapers" "Fetching a list of wallpapers..."
URL="${WALLHAVEN_BASE_URL}/search?${TAGS}${CATEGORIES}${PURITY}${SIZE}${RATIOS}${COLORS}${AI_FILTER}${SORTING}${RANGE}"
CURL_CMD="${CURL_BASE_CMD} \"${URL}\""
RESULT="$(eval ${CURL_CMD})"
NO_OF_IMAGES="$(echo "${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."
notify-send -r 1234 -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)"
@ -88,11 +88,11 @@ if [ "${ITEM_PAGE}" -gt 0 ]; then
RESULT="$(eval ${CURL_CMD})"
fi
ID="$(echo "${RESULT}" | jq -r ".data[${ITEM_NUMBER}].id")"
notify-send -u normal -a Wallpapers -i information -t 5000 "Wallpapers" "Got ${NO_OF_IMAGES} images. Using image ${ID} from page $((ITEM_PAGE+1)) ..."
notify-send -r 1234 -u normal -a Wallpapers -i information -t 5000 "Wallpapers" "Got ${NO_OF_IMAGES} images. Using image ${ID} from page $((ITEM_PAGE+1)) ..."
IMAGE_URL="$(echo "${RESULT}" | jq -r ".data[${ITEM_NUMBER}].path")"
FILENAME="${IMAGE_URL##*/}"
notify-send -u normal -a Wallpapers -i information -t 5000 "Wallpapers" "Downloading image: ${IMAGE_URL}"
notify-send -r 1234 -u normal -a Wallpapers -i information -t 5000 "Wallpapers" "Downloading image: ${IMAGE_URL}"
curl --silent -L --output-dir "${DIR}" -o "${FILENAME}" "${IMAGE_URL}"
notify-send -u normal -a Wallpapers -i information -t 5000 "Wallpapers" "Downloaded image: ${DIR}/${FILENAME}"
notify-send -r 1234 -u normal -a Wallpapers -i information -t 5000 "Wallpapers" "Downloaded image: ${DIR}/${FILENAME}"
echo "${DIR}/${FILENAME}"