Hello, first of all, thanks for sharing the config!
I tried using your config but the media plugin didn't work for some reason with Apple Music (Currently on macOS Sequoia 15.6.1)
I was going to make a PR but somehow my extra branch also included all my previous commits on the main branch after forking it (for my own configs).
I found this tool called media-control. The author mentioned that it's experimental though, but I find it also able to play literally anything even from YouTube on Firefox/Chromium, etc. If you run media control get -h it returns a JSON that I think that it is relatively safe to assume that the playbackRate value is safe enough to tell whether a media is paused/being played.
Here's a snippet I tinkered around with it. I purely use Apple Music for this example, but you can add more app IDs using the bundleIdentifier values if you want. I was lazy so I just used Copilot in VSCode for it, but it helped getting it working on my side.
plugins/music.sh
#!/bin/bash
ICON_PLAY=" "
ICON_PAUSE=" "
ICON_NOMEDIA=" "
MEDIA_JSON=$(media-control get -h)
# Default case for fallback
if [ -z "$MEDIA_JSON" ]; then
sketchybar --set $NAME icon="$ICON_PLAY" \
label="Player Not Open" \
drawing=on
exit 0
fi
BUNDLE_ID=$(echo "$MEDIA_JSON" | jq -r '.bundleIdentifier')
PLAYBACK_RATE=$(echo "$MEDIA_JSON" | jq -r '.playbackRate')
TITLE=$(echo "$MEDIA_JSON" | jq -r '.title')
ARTIST=$(echo "$MEDIA_JSON" | jq -r '.artist')
# Check if the media source is NOT Apple Music
if [ "$BUNDLE_ID" != "com.apple.Music" ]; then
sketchybar --set $NAME drawing=on \
icon="$ICON_NOMEDIA" \
label="None Detected - Open Apple Music"
exit 0
fi
# Do these only if Apple Music is running (i.e. it appears as the only Now Playing widget in the Control Center)
if [ "$PLAYBACK_RATE" -gt 0 ]; then
sketchybar --set $NAME icon="$ICON_PLAY" \
label="$TITLE - $ARTIST" \
drawing=on
else
sketchybar --set $NAME icon="$ICON_PAUSE" \
label="$TITLE - $ARTIST" \
drawing=on
fi
English isn't my primary language, but I hope it's understandable enough. Do try it out though.
Hello, first of all, thanks for sharing the config!
I tried using your config but the media plugin didn't work for some reason with Apple Music (Currently on macOS Sequoia 15.6.1)
I was going to make a PR but somehow my extra branch also included all my previous commits on the main branch after forking it (for my own configs).
I found this tool called media-control. The author mentioned that it's experimental though, but I find it also able to play literally anything even from YouTube on Firefox/Chromium, etc. If you run
media control get -hit returns a JSON that I think that it is relatively safe to assume that theplaybackRatevalue is safe enough to tell whether a media is paused/being played.Here's a snippet I tinkered around with it. I purely use Apple Music for this example, but you can add more app IDs using the
bundleIdentifiervalues if you want. I was lazy so I just used Copilot in VSCode for it, but it helped getting it working on my side.plugins/music.shEnglish isn't my primary language, but I hope it's understandable enough. Do try it out though.