sketchybar: scroll music widget when length exceeds 50 char

This commit is contained in:
Nico 2025-10-05 03:55:03 +11:00
parent b1f5d44dd1
commit 6cb10c6f3e
Signed by: nico
SSH key fingerprint: SHA256:XuacYOrGqRxC3jVFjfLROn1CSvLz85Dec6N7O9Gwu/0
2 changed files with 4 additions and 1 deletions

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# sketchybar doesn't like it when the line doesn't end with a carriage return # sketchybar doesn't like it when the line doesn't end with a carriage return
SONG="$(osascript -e 'tell application "Music" to if player state is playing then artist of current track & " - " & name of current track' | head -c 65 && echo '\r')" SONG="$(osascript -e 'tell application "Music" to if player state is playing then artist of current track & " - " & name of current track')"
if [[ "$(echo $SONG | wc -w | sed 's/ //g')" != "0" ]]; then if [[ "$(echo $SONG | wc -w | sed 's/ //g')" != "0" ]]; then
sketchybar --set "$NAME" label="${SONG}" background.drawing=true icon.drawing=true sketchybar --set "$NAME" label="${SONG}" background.drawing=true icon.drawing=true

View file

@ -80,6 +80,9 @@ sketchybar --add item music left \
background.padding_right=0 \ background.padding_right=0 \
background.padding_left=0 \ background.padding_left=0 \
background.drawing=false \ background.drawing=false \
scroll_texts=1 \
label.max_chars=50 \
label.scroll_duration=500 \
background.color=$PRIMARY_COLOUR \ background.color=$PRIMARY_COLOUR \
icon.color=$BACKGROUND_COLOUR \ icon.color=$BACKGROUND_COLOUR \
label.color=$BACKGROUND_COLOUR \ label.color=$BACKGROUND_COLOUR \