From 5fb19f10389b70ee2389755106092a9ef6c64598 Mon Sep 17 00:00:00 2001 From: David Moc Date: Sun, 24 May 2026 11:48:07 +0200 Subject: Go --- polybar/scripts/music-status.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 polybar/scripts/music-status.sh (limited to 'polybar/scripts/music-status.sh') diff --git a/polybar/scripts/music-status.sh b/polybar/scripts/music-status.sh new file mode 100755 index 0000000..229e058 --- /dev/null +++ b/polybar/scripts/music-status.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -euo pipefail + +if ! command -v playerctl >/dev/null 2>&1; then + echo "n/a" + exit 0 +fi + +status="$(playerctl status 2>/dev/null || true)" +if [ -z "$status" ]; then + echo "off" + exit 0 +fi + +artist="$(playerctl metadata artist 2>/dev/null || true)" +title="$(playerctl metadata title 2>/dev/null || true)" + +if [ -n "$artist" ] && [ -n "$title" ]; then + text="$artist - $title" +elif [ -n "$title" ]; then + text="$title" +else + text="$status" +fi + +case "$status" in + Playing) + prefix="%{F#98971a}>%{F-}" + ;; + Paused) + prefix="%{F#d79921}=%{F-}" + ;; + *) + prefix="-" + ;; +esac + +printf '%s %s\n' "$prefix" "$(printf '%s' "$text" | cut -c 1-32)" -- cgit v1.2.3