2018-03-01 00:47:14 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# https://community.spotify.com/t5/Help-Desktop-Linux-Windows-Web/Conky-Spotify-quot-Now-Playing-quot-scripts/m-p/812541#M88825
|
|
|
|
|
|
|
|
SYMBOL="♫ "
|
|
|
|
|
|
|
|
ARTIST="$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "artist"|egrep -v "artist"|egrep -v "array"|cut -b 27-|cut -d '"' -f 1|egrep -v ^$)"
|
|
|
|
|
|
|
|
TITLE="$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 1 "title"|egrep -v "title"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$)"
|
|
|
|
|
|
|
|
#TIME="$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "time"|cut -d " " -f 3|cut -c 6-)"
|
|
|
|
|
|
|
|
#if [ ! -f "/tmp/tunes_time" ] ; then
|
|
|
|
# TIME_OLD=0
|
|
|
|
#else
|
|
|
|
# TIME_OLD=$(cat /tmp/tunes_time)
|
|
|
|
#fi
|
|
|
|
#
|
|
|
|
#if [ $TIME == $TIME_OLD ]
|
|
|
|
# then
|
|
|
|
# exit 0
|
|
|
|
#fi
|
|
|
|
|
|
|
|
#echo "$TIME" > /tmp/tunes_time
|
|
|
|
|
|
|
|
if [ -n "$ARTIST" ]
|
|
|
|
then
|
|
|
|
index=$(expr index "$ARTIST" -)
|
|
|
|
if [ $index -gt 0 ]
|
|
|
|
then
|
|
|
|
length=$((${#ARTIST} - $index + 2))
|
|
|
|
ARTIST=${ttest::-$length}
|
|
|
|
fi
|
2018-04-30 00:37:31 +02:00
|
|
|
OUTPUT=" | $SYMBOL $ARTIST - $TITLE"
|
2018-03-01 00:47:14 +01:00
|
|
|
if [ ${#OUTPUT} -gt 35 ]
|
|
|
|
then
|
2018-04-30 00:37:31 +02:00
|
|
|
OUTPUT=" | $SYMBOL $TITLE"
|
2018-03-01 00:47:14 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
OUTPUT=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$OUTPUT"
|
|
|
|
|
|
|
|
|