You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the original code, inside spotify-panel.sh, when sp.sh eval is called with the eval bash function, the title or album may not be displayed because of quotes that end the string unexpectedly. For this, I changed how the metadata is parsed inside spotify-panel.sh, adding a function and changing how the title is trimmed.
#!/usr/bin/env bashreadonly DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"&& pwd)"declare -A SPOTIFY_METADATA
# ... existing code (encode function)functionfetch_spotify_metadata {
whileread -r line;do
key="${line%%=*}"
value="${line#*=}"
value="${value%\"}"
value="${value#\"}"
SPOTIFY_METADATA["$key"]="$value"done<<(${DIR}/sp.sh eval)
}
if pidof spotify &> /dev/null;then# call this function to populate SPOTIFY_METADATA
fetch_spotify_metadata
SPOTIFY_TITLE=${SPOTIFY_METADATA["SPOTIFY_TITLE"]}
SPOTIFY_ARTIST=${SPOTIFY_METADATA["SPOTIFY_ARTIST"]}
SPOTIFY_ALBUM=${SPOTIFY_METADATA["SPOTIFY_ALBUM"]}# grab window id
WINDOW_ID=$(wmctrl -l | grep "${SPOTIFY_ARTIST} - ${SPOTIFY_TITLE}\|Spotify"| awk '{print $1}')# trim the title
MAX_LENGTH=20
DISPLAY_TITLE=$(python3 -c "import sys; title=sys.argv[1]; print(title[:$MAX_LENGTH] + '...' if len(title) > $MAX_LENGTH else title)""$SPOTIFY_TITLE")echo"<img>${ICON}</img>"# ...rest of code
The text was updated successfully, but these errors were encountered:
With the original code, inside
spotify-panel.sh
, whensp.sh eval
is called with the eval bash function, the title or album may not be displayed because of quotes that end the string unexpectedly. For this, I changed how the metadata is parsed insidespotify-panel.sh
, adding a function and changing how the title is trimmed.The text was updated successfully, but these errors were encountered: