25 lines
603 B
Bash
Executable File
25 lines
603 B
Bash
Executable File
#!/bin/bash
|
|
|
|
CACHE="$HOME/.cache/waybar-cover.jpg"
|
|
TMP="$HOME/.cache/waybar-cover.tmp.jpg"
|
|
|
|
status=$(playerctl status 2>/dev/null)
|
|
|
|
if [ "$status" = "Playing" ]; then
|
|
artist=$(playerctl metadata artist)
|
|
title=$(playerctl metadata title)
|
|
url=$(playerctl metadata mpris:artUrl)
|
|
|
|
if [[ "$url" == file://* ]]; then
|
|
cp "${url#file://}" "$TMP"
|
|
else
|
|
curl -sL "$url" -o "$TMP"
|
|
fi
|
|
|
|
mv -f "$TMP" "$CACHE"
|
|
|
|
echo "{\"text\": \"$artist - $title\", \"tooltip\": \"$artist - $title\", \"class\": \"playing\", \"alt\": \"$CACHE\"}"
|
|
else
|
|
echo "{\"text\": \" \", \"class\": \"stopped\"}"
|
|
fi
|