2023-05-16 00:19:04 +05:30
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2023-05-18 20:09:34 +05:30
|
|
|
DIR="${1:-/tmp}"
|
|
|
|
mkdir -p "$DIR"
|
2023-05-16 00:19:04 +05:30
|
|
|
|
2023-05-18 20:09:34 +05:30
|
|
|
notify-send -r 9897 -i information -t 1000 "Wallpapers" "Downloading..."
|
|
|
|
URL="https://wallhaven.cc/api/v1/search?categories=100&purity=100&atleast=1920x1080&ratios=16x9&sorting=random"
|
|
|
|
ID="$(curl --silent "$URL" | jq -r '.data[0].id')"
|
|
|
|
IMAGE_META=$(curl --silent "https://wallhaven.cc/api/v1/w/$ID")
|
|
|
|
IMAGE_URL="$(echo "$IMAGE_META" | jq -r '.data.path')"
|
|
|
|
IMAGE_ID="$(echo "$IMAGE_META" | jq -r '.data.id')"
|
|
|
|
FILENAME="wallhaven-$IMAGE_ID"
|
|
|
|
curl --silent -L --output "/tmp/$FILENAME" "$IMAGE_URL"
|
|
|
|
convert "/tmp/$FILENAME" "$DIR/$FILENAME.jpg"
|
|
|
|
echo "$DIR/$FILENAME.jpg"
|
2023-05-16 00:19:04 +05:30
|
|
|
|