summaryrefslogtreecommitdiff
path: root/mac/.config/sketchybar/plugins/youtube-music.sh
blob: eb4ef8ef433813d5daec02ae051858a127465925 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash

SONG_INFO=$(curl -s 0.0.0.0:26538/api/v1/song-info)

PAUSED="$(echo "$SONG_INFO" | jq -r '.isPaused')"
CURRENT_SONG="$(echo "$SONG_INFO" | jq -r '.title + " - " + .artist')"
ARTWORK="$(echo "$SONG_INFO" | jq -r '.imageSrc')"
ARTWORK_LOCATION="$(curl -O --output-dir "${TMPDIR%/}" -s --remote-name -w "%{filename_effective}" "$ARTWORK")"

if [ "$PAUSED" = true ]; then
  ICON=􀊄
else
  ICON=􁁒
fi

sketchybar --set music-artwork background.image="$ARTWORK_LOCATION"
sketchybar --set music label="$CURRENT_SONG" icon="$ICON" drawing=on