26 lines
530 B
Bash
Executable File
26 lines
530 B
Bash
Executable File
#!/bin/sh
|
|
|
|
class=$(playerctl metadata --player=spotify --format '{{lc(status)}}')
|
|
icon=""
|
|
|
|
case "$class" in
|
|
"playing")
|
|
info=$(playerctl metadata --player=spotify --format '{{artist}} - {{title}}')
|
|
if [ "${#info}" -gt 40 ]; then
|
|
info=$(printf '%.40s...' "$info")
|
|
fi
|
|
text="$info $icon"
|
|
;;
|
|
"paused")
|
|
text="$icon"
|
|
;;
|
|
"stopped")
|
|
text=""
|
|
;;
|
|
*)
|
|
text=""
|
|
;;
|
|
esac
|
|
|
|
printf '{"text":"%s", "class":"%s"}\n' "$text" "$class"
|