configure wallpaper tags on the fly

This commit is contained in:
Adithya 2023-10-13 12:36:02 +05:30
parent d7190cee8d
commit 0743307cac
Signed by: adtya
GPG key ID: 48FC9915FFD326D0
2 changed files with 8 additions and 1 deletions

View file

@ -65,6 +65,7 @@ _: {
files = [
".config/gh/hosts.yml"
".config/wallpaper_tags"
];
};
}

View file

@ -5,8 +5,14 @@ set -eu
DIR="${1:-/tmp}"
mkdir -p "$DIR"
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}"
TAGS="$(<$CONFIG_DIR/wallpaper_tags)"
if [ -n "$TAGS" ]; then
TAGS="q=$TAGS&"
fi
notify-send -r 9897 -i information -t 1000 "Wallpapers" "Downloading..."
URL="https://wallhaven.cc/api/v1/search?categories=100&purity=100&atleast=3840x2160&ratios=16x9&sorting=random"
URL="https://wallhaven.cc/api/v1/search?${TAGS}categories=100&purity=100&atleast=3840x2160&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')"