2025-06-14 17:17:10 -05:00

33 lines
791 B
Bash
Executable File

#!/bin/sh
api="https://nekos.life/api/v2/img/wallpaper"
MONITOR="HDMI-A-1"
TMPDIR=$(mktemp -d) || { echo "FAILED TO CREATE TMPDIR 🥀"; exit 1; }
wallpaper_url=$(curl -sf "$api" | awk -F'"' '/url/{print $4; exit}') || {
echo "API request failed 🥀"
exit 1
}
extension=$(echo "$wallpaper_url" | sed -E 's/.*\.([a-zA-Z]+).*/\1/' | head -c 5)
wallpaper="$TMPDIR/wallpaper.$extension"
echo $wallpaper_url " into " $wallpaper
curl -sfL "$wallpaper_url" -o "$TMPDIR/wallpaper.$extension" || {
echo "Download failed 🥀"
exit 1
}
if [ ! -s "$wallpaper" ]; then
echo "Empty wallpaper file 🥀"
exit 1
fi
# Ensure we unload them all
hyprctl hyprpaper unload all&>/dev/null
# Apply the selected wallpaper
hyprctl hyprpaper reload $MONITOR,"$wallpaper"&>/dev/null