#!/usr/bin/env bash

MAXLEN=25
STATUS=$(playerctl status 2>/dev/null)  # playing, paused, stopped
TITLE=$(playerctl metadata title 2>/dev/null)

# Decide emoji based on status
if [ "$STATUS" = "Playing" ]; then
    EMOJI="▶"
elif [ "$STATUS" = "Paused" ]; then
    EMOJI="⏸"
else
    EMOJI="⏹"
fi

# If no song
if [ -z "$TITLE" ]; then
    echo "🕊️ Chillin'"
else
    # Truncate if too long
    if [ ${#TITLE} -gt $MAXLEN ]; then
        TITLE="${TITLE:0:MAXLEN}…"
    fi
    # Underline with Polybar formatting and show emoji
    echo "%{+u}%{F#8be9fd}$EMOJI $TITLE%{-u}%{F-}"
fi

