From d2b62c9d6f30a0ea88b2a235cde120cd10ba332b Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Sat, 11 Jul 2026 22:14:43 -0400 Subject: Sketchybar now, got tired of the battery issue --- .../modules/sketchybar/bar-config/plugins/spotify.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 users/ryan/modules/sketchybar/bar-config/plugins/spotify.sh (limited to 'users/ryan/modules/sketchybar/bar-config/plugins/spotify.sh') 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 @@ +#!/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 -- cgit v1.3