configuration.nix/packages/scripts/wallhaven.sh

22 lines
693 B
Bash
Raw Normal View History

2023-05-16 00:19:04 +05:30
#!/bin/sh
set -eu
wallpaper() {
FILENAME="/tmp/image-${RANDOM}"
2023-05-18 16:06:40 +05:30
notify-send -r 9897 -i information -t 1000 "Wallpapers" "Downloading..."
2023-05-16 00:19:04 +05:30
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_URL="$(curl --silent "https://wallhaven.cc/api/v1/w/$ID" | jq -r '.data.path')"
curl --silent -L --output "$FILENAME" "$IMAGE_URL"
echo $FILENAME
}
2023-05-18 16:06:40 +05:30
swww query || swww init
convert "$(wallpaper)" "/tmp/wallpaper.jpg" && swww img "/tmp/wallpaper.jpg"
2023-05-16 00:19:04 +05:30
convert "$(wallpaper)" "/tmp/lockpaper.jpg"
2023-05-18 16:06:40 +05:30
notify-send -r 9897 -i information -t 1000 "Wallpaper" "Wallpaper changed."