#!/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"