2021-08-09 17:06:10 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
RUNNING=$(osascript -e 'if application "Spotify" is running then return 0')
|
|
|
|
if [ "$RUNNING" == "" ]; then
|
|
|
|
RUNNING=1
|
|
|
|
fi
|
|
|
|
PLAYING=1
|
|
|
|
TRACK=""
|
|
|
|
ALBUM=""
|
|
|
|
ARTIST=""
|
|
|
|
if [ "$(osascript -e 'if application "Spotify" is running then tell application "Spotify" to get player state')" == "playing" ]; then
|
|
|
|
PLAYING=0
|
|
|
|
TRACK=$(osascript -e 'tell application "Spotify" to get name of current track')
|
|
|
|
ARTIST=$(osascript -e 'tell application "Spotify" to get artist of current track')
|
|
|
|
ALBUM=$(osascript -e 'tell application "Spotify" to get album of current track')
|
|
|
|
fi
|
|
|
|
if [ $RUNNING -eq 0 ] && [ $PLAYING -eq 0 ]; then
|
|
|
|
if [ "$ARTIST" == "" ]; then
|
2021-09-04 08:46:32 +00:00
|
|
|
sketchybar -m set $NAME label " $TRACK $ALBUM"
|
2021-08-09 17:06:10 +00:00
|
|
|
else
|
2021-09-04 08:46:32 +00:00
|
|
|
sketchybar -m set $NAME label " $TRACK $ARTIST"
|
2021-08-09 17:06:10 +00:00
|
|
|
fi
|
|
|
|
else
|
2021-09-04 08:46:32 +00:00
|
|
|
sketchybar -m set $NAME label ""
|
2021-08-09 17:06:10 +00:00
|
|
|
fi
|