configurable wallpapers ftw
This commit is contained in:
parent
0743307cac
commit
33e2f8a23a
2 changed files with 23 additions and 3 deletions
|
@ -12,6 +12,7 @@
|
|||
jq,
|
||||
curl,
|
||||
ytfzf,
|
||||
libsecret
|
||||
}:
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "scripts";
|
||||
|
@ -45,7 +46,7 @@ stdenvNoCC.mkDerivation {
|
|||
wrapProgram $out/bin/power-menu --prefix PATH : ${lib.makeBinPath [libnotify rofi-wayland hyprland]}
|
||||
wrapProgram $out/bin/tmux-sessions --prefix PATH : ${lib.makeBinPath [tmux kitty rofi-wayland]}
|
||||
wrapProgram $out/bin/chpaper --prefix PATH : ${lib.makeBinPath [imagemagick libnotify swww]}
|
||||
wrapProgram $out/bin/wallhaven --prefix PATH : ${lib.makeBinPath [imagemagick libnotify jq curl]}
|
||||
wrapProgram $out/bin/wallhaven --prefix PATH : ${lib.makeBinPath [imagemagick libnotify jq curl libsecret]}
|
||||
wrapProgram $out/bin/youtube --prefix PATH : ${lib.makeBinPath [kitty ytfzf rofi-wayland]}
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -6,13 +6,32 @@ DIR="${1:-/tmp}"
|
|||
mkdir -p "$DIR"
|
||||
|
||||
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
TAGS="$(<$CONFIG_DIR/wallpaper_tags)"
|
||||
if [ ! -e $CONFIG_DIR/wallpaper_config ]; then
|
||||
echo '{"tags":null,"categories":"100","purity":"100"}' | jq > $CONFIG_DIR/wallpaper_config
|
||||
fi
|
||||
|
||||
TAGS="$(cat $CONFIG_DIR/wallpaper_config | jq -r '.tags // empty')"
|
||||
if [ -n "$TAGS" ]; then
|
||||
TAGS="q=$TAGS&"
|
||||
fi
|
||||
|
||||
CATEGORIES="$(cat $CONFIG_DIR/wallpaper_config | jq -r '.categories // empty')"
|
||||
if [ -n "$CATEGORIES" ]; then
|
||||
CATEGORIES="categories=$CATEGORIES&"
|
||||
fi
|
||||
|
||||
PURITY="$(cat $CONFIG_DIR/wallpaper_config | jq -r '.purity // empty')"
|
||||
if [ -n "$PURITY" ]; then
|
||||
PURITY="purity=$PURITY&"
|
||||
fi
|
||||
|
||||
WALLHAVEN_API_KEY="$(secret-tool lookup application wallhaven-api-key)"
|
||||
if [ -n "$WALLHAVEN_API_KEY"]; then
|
||||
WALLHAVEN_API_KEY="apikey=$WALLHAVEN_API_KEY&"
|
||||
fi
|
||||
|
||||
notify-send -r 9897 -i information -t 1000 "Wallpapers" "Downloading..."
|
||||
URL="https://wallhaven.cc/api/v1/search?${TAGS}categories=100&purity=100&atleast=3840x2160&ratios=16x9&sorting=random"
|
||||
URL="https://wallhaven.cc/api/v1/search?${WALLHAVEN_API_KEY}${TAGS}${CATEGORY}${PURITY}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')"
|
||||
|
|
Loading…
Reference in a new issue