/ modules / home / programs / sketchybar / sketchybar / plugins / spotifyIndicator.sh
spotifyIndicator.sh
 1  #!/usr/bin/env sh
 2  RUNNING=$(osascript -e 'if application "Spotify" is running then return 0')
 3  if [ "$RUNNING" == "" ]; then
 4    RUNNING=1
 5  fi
 6  PLAYING=1
 7  TRACK=""
 8  ALBUM=""
 9  ARTIST=""
10  if [ "$(osascript -e 'if application "Spotify" is running then tell application "Spotify" to get player state')" == "playing" ]; then
11    PLAYING=0
12    TRACK=$(osascript -e 'tell application "Spotify" to get name of current track')
13    ARTIST=$(osascript -e 'tell application "Spotify" to get artist of current track')
14    ALBUM=$(osascript -e 'tell application "Spotify" to get album of current track')
15  fi
16  if [ $RUNNING -eq 0 ] && [ $PLAYING -eq 0 ]; then
17    if [ "$ARTIST" == "" ]; then
18      sketchybar --set $NAME label=" $TRACK - $ALBUM" --set '/spot.*/' drawing=on
19    else
20      sketchybar --set $NAME label=" $TRACK - $ARTIST" --set '/spot.*/' drawing=on
21    fi
22  else
23    sketchybar --set '/spot.*/' drawing=off
24  fi