Files
i3wm-ubuntu-dotfiles/.config/polybar/scripts/music.sh
T
2026-01-29 23:19:44 +05:30

28 lines
595 B
Bash
Executable File

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