#!/usr/bin/env bash # custom/spotify -> now playing, driven by the native media_change event. source "$HOME/.config/sketchybar/icons.sh" # Waybar on-click: playerctl play-pause if [ "$1" = "toggle" ]; then osascript -e 'tell application "Spotify" to playpause' 2>/dev/null exit 0 fi STATE="$(printf '%s' "$INFO" | sed -nE 's/.*"state":"([^"]*)".*/\1/p')" TITLE="$(printf '%s' "$INFO" | sed -nE 's/.*"title":"([^"]*)".*/\1/p')" ARTIST="$(printf '%s' "$INFO" | sed -nE 's/.*"artist":"([^"]*)".*/\1/p')" # exec-if check-for-music -> only draw while something is playing if [ "$STATE" = "playing" ] && [ -n "$TITLE" ]; then sketchybar --set "$NAME" drawing=on label="$TITLE - $ARTIST" else sketchybar --set "$NAME" drawing=off fi