24 lines
411 B
Bash
Executable File
24 lines
411 B
Bash
Executable File
#!/bin/bash
|
|
|
|
CACHE="$HOME/.cache/nowplaying-cover.jpg"
|
|
TMP="$HOME/.cache/nowplaying-cover.tmp.jpg"
|
|
|
|
status=$(playerctl status 2>/dev/null)
|
|
|
|
if [ "$status" != "Playing" ]; then
|
|
rm -f "$CACHE"
|
|
exit 0
|
|
fi
|
|
|
|
url=$(playerctl metadata mpris:artUrl)
|
|
|
|
[ -z "$url" ] && rm -f "$CACHE" && exit 0
|
|
|
|
if [[ "$url" == file://* ]]; then
|
|
cp "${url#file://}" "$TMP"
|
|
else
|
|
curl -sL "$url" -o "$TMP"
|
|
fi
|
|
|
|
mv -f "$TMP" "$CACHE"
|