A challenge for the conky/bash specialists.
It is time i send you all the details. I am at a loss why the script works from the terminal but not via conky?
I have tried variations of exec, execi execp,execpi,texeci ... No success. Turned over my script using while...done
At the moment i think it is or
- a conky problem not starting the .sh file
- a wget problem with the picture
Code: Select all
${font GeosansLight:size=15}${color 000000}\
${execi 5 echo `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 "album"|egrep -v "album"|egrep -v "array"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$`}
${execi 5 echo `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 ^$`}
${execi 5 echo `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 ^$`}
${execi 10 $HOME/.conky/Aurora/scripts/spotify-api/getcover.sh}
${image ~/.conky/Aurora/scripts/spotify-api/lastpic -p 100,100 -s 540x540 -f 2}
AND IT DOES. But no picture is downloaded.
If i run this, when i change the spotify song, in the terminal. Everything works.
I also tried a lot of wget -options without success.
Code for getcover.sh
Code: Select all
#Variable the first song you play
first_trackid=`cat ~/.conky/Aurora/scripts/spotify-api/first_trackid.txt`
#get the current song and put in varible
new_trackid=`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 "trackid" | grep variant | awk {'print $NF'} | cut -d ':' -f3 | cut -d '"' -f 1`
#write the trackid to file to compare later
echo $new_trackid > ~/.conky/Aurora/scripts/spotify-api/new_trackid.txt
#testing
echo First $first_trackid
echo New $new_trackid
sleep 2
#end testing
#if the old song and the new song are the same - do nothing
#or if the old song and the new song are not the same
#then the song has changed - get a new album cover
if [ "$new_trackid" != "$first_trackid" ]; then
#rm ~/.conky/Aurora/scripts/spotify-api/lastpic
#we get the imgcurl by chopping the response of the api to the specific new_trackid
imgurl=`curl -X GET https://api.spotify.com/v1/tracks/$new_trackid | grep '"url" : ' | sed '1q;d' | cut -d '"' -f4`
echo $imgurl
#different sizes
#imgurl=`curl -X GET https://api.spotify.com/v1/tracks/$new_trackid | grep '"url" : ' | sed '2q;d' | cut -d '"' -f4`
#imgurl=`curl -X GET https://api.spotify.com/v1/tracks/$new_trackid | grep '"url" : ' | sed '3q;d' | cut -d '"' -f4`
#get the picture and save it as lastpic
wget -O newpic $imgurl
cp newpic lastpic
sleep 3
rm newpic
#curl -o $imgurl > lastpic
sleep 3
#testing
echo first $first_trackid
echo new $new_trackid
#end testing
#save the new song to the first_track file to compare later
echo $new_trackid > ~/.conky/Aurora/scripts/spotify-api/first_trackid.txt
fi