dotfiles/de/home/.config/eww/scripts/home/nowplayingart.sh
2025-07-18 13:30:02 -07:00

22 lines
669 B
Bash
Executable file

#!/usr/bin/env bash
playerctl metadata --format "{{mpris:artUrl}}" --follow | while IFS= read -r line; do
if [[ $line == *"http"* ]]; then
cache_dir="$XDG_RUNTIME_DIR/album_art_cache"
mkdir -p "$cache_dir"
file_name=$(basename "$line")
file_path="$cache_dir/$file_name"
# Check if file exists
if [ -e "$file_path" ]; then
# File exists, return path immediately
echo "$file_path"
else
curl --output "$file_path" "$line" > /dev/null 2>&1
echo "$file_path"
fi
else
# artUrl doesn't have a link, nothing to do
echo "$line"
fi
done