diff options
Diffstat (limited to 'users/ryan/modules/sketchybar/bar-config/plugins/spotify.sh')
| -rwxr-xr-x | users/ryan/modules/sketchybar/bar-config/plugins/spotify.sh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/users/ryan/modules/sketchybar/bar-config/plugins/spotify.sh b/users/ryan/modules/sketchybar/bar-config/plugins/spotify.sh new file mode 100755 index 0000000..8d91297 --- /dev/null +++ b/users/ryan/modules/sketchybar/bar-config/plugins/spotify.sh | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | # custom/spotify -> now playing, driven by the native media_change event. | ||
| 3 | source "$HOME/.config/sketchybar/icons.sh" | ||
| 4 | |||
| 5 | # Waybar on-click: playerctl play-pause | ||
| 6 | if [ "$1" = "toggle" ]; then | ||
| 7 | osascript -e 'tell application "Spotify" to playpause' 2>/dev/null | ||
| 8 | exit 0 | ||
| 9 | fi | ||
| 10 | |||
| 11 | STATE="$(printf '%s' "$INFO" | sed -nE 's/.*"state":"([^"]*)".*/\1/p')" | ||
| 12 | TITLE="$(printf '%s' "$INFO" | sed -nE 's/.*"title":"([^"]*)".*/\1/p')" | ||
| 13 | ARTIST="$(printf '%s' "$INFO" | sed -nE 's/.*"artist":"([^"]*)".*/\1/p')" | ||
| 14 | |||
| 15 | # exec-if check-for-music -> only draw while something is playing | ||
| 16 | if [ "$STATE" = "playing" ] && [ -n "$TITLE" ]; then | ||
| 17 | sketchybar --set "$NAME" drawing=on label="$TITLE - $ARTIST" | ||
| 18 | else | ||
| 19 | sketchybar --set "$NAME" drawing=off | ||
| 20 | fi | ||
