Nixos-Config/configs/waybar/spotify_status.sh
2026-04-22 16:52:05 -03:00

26 lines
472 B
Bash

#!/usr/bin/env sh
player="$(playerctl -l 2>/dev/null | rg '^spotifyd\.instance' -m1 || true)"
if [ -z "$player" ]; then
exit 0
fi
status="$(playerctl -p "$player" status 2>/dev/null || true)"
text="$(playerctl -p "$player" metadata --format '{{artist}} - {{title}}' 2>/dev/null || true)"
if [ -z "$text" ]; then
exit 0
fi
case "$status" in
Playing)
printf ' %s\n' "$text"
;;
Paused)
printf ' %s\n' "$text"
;;
*)
exit 0
;;
esac