sketchybar: only get playing music if Music.app is open

fixes bug where music would keep on starting itself up
This commit is contained in:
Nico 2025-10-17 00:26:09 +11:00
parent 3d46bbf25d
commit ad7c4f42e7
Signed by: nico
SSH key fingerprint: SHA256:XuacYOrGqRxC3jVFjfLROn1CSvLz85Dec6N7O9Gwu/0

View file

@ -1,7 +1,10 @@
#!/bin/sh
# sketchybar doesn't like it when the line doesn't end with a carriage return
SONG="$(osascript -e 'tell application "Music" to if player state is playing then artist of current track & " - " & name of current track')"
if pgrep "Music"; then
SONG="$(osascript -e 'tell application "Music" to if player state is playing then artist of current track & " - " & name of current track')"
fi
if [[ "$(echo $SONG | wc -w | sed 's/ //g')" != "0" ]]; then
sketchybar --set "$NAME" label="${SONG}" drawing=true