Skip to content

Instantly share code, notes, and snippets.

@red-noise
Last active April 29, 2021 04:51
Show Gist options
  • Save red-noise/9789642 to your computer and use it in GitHub Desktop.
Save red-noise/9789642 to your computer and use it in GitHub Desktop.
Spotify script for Conky
#This is ho you should edit your conkyrc file in order to get the spotify player.
####################
# - MEDIA PLAYER - #
####################
${if_running spotify}${voffset -2}${font Liberation Sans:style=Bold:size=8}
${voffset -10}${goto 73}Title:
${goto 73}${color2}${exec ~/.conkycolors/spotify/spotify_info_title}${color}
${goto 73}Artist:
${goto 73}${color2}${exec ~/.conkycolors/spotify/spotify_info_artist}${color}
${goto 73}Album:
${goto 73}${color2}${exec ~/.conkycolors/spotify/spotify_info_album}${color}
${voffset -20}
${exec ~/.conkycolors/spotify/spotify_album_cover}
${image ~/.conkycolors/spotify/last_album_pic.png -p 0,180 -s 60x60}
${else}${voffset -5}${color0}${font ConkyColors:size=16}G${font}${color}${voffset -10}${goto 32}Spotify: ${color2}off${color}${voffset 7}
${endif}
#!/bin/bash
# Written by Demetrio Ferro <[email protected]> <https://twitter.com/DemetrioFerro>
# Distributed under license GPLv3+ GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY. YOU USE AT YOUR OWN RISK. THE AUTHOR
# WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY
# OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.
# See the GNU General Public License for more details.
first_cover=""
while :
do
new_cover=$(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 "artUrl"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$)
if [ "$new_cover" != "$first_cover" ]
then
first_cover="$new_cover"
wget -O ~/.conkycolors/spotify/last_album_pic.png $new_cover
fi
sleep 1
done
#!/bin/bash
# Written by Demetrio Ferro <[email protected]> <https://twitter.com/DemetrioFerro>
# Distributed under license GPLv3+ GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY. YOU USE AT YOUR OWN RISK. THE AUTHOR
# WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY
# OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.
# See the GNU General Public License for more details.
first_album=""
while :
do
new_album=`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 "album"|egrep -v "album"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$`
if [ "$new_album" != "$first_album" ]
then
first_album="$new_album"
echo "$new_album"
fi
sleep 1
done
#!/bin/bash
# Written by Demetrio Ferro <[email protected]> <https://twitter.com/DemetrioFerro>
# Distributed under license GPLv3+ GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY. YOU USE AT YOUR OWN RISK. THE AUTHOR
# WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY
# OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.
# See the GNU General Public License for more details.
first_artist=""
while :
do
new_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 ^$`
if [ "$new_artist" != "$first_artist" ]
then
first_artist="$new_artist"
echo "$new_artist"
fi
sleep 1
done
#!/bin/bash
# Written by Demetrio Ferro <[email protected]> <https://twitter.com/DemetrioFerro>
# Distributed under license GPLv3+ GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY. YOU USE AT YOUR OWN RISK. THE AUTHOR
# WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY
# OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.
# See the GNU General Public License for more details.
first_title=""
while :
do
new_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 ^$`
if [ "$new_title" != "$first_title" ]
then
first_title="$new_title"
echo "$new_title"
fi
sleep 1
done
@VitorCoelho
Copy link

Anyone tested on ubuntu 15?

@xywei
Copy link

xywei commented Feb 25, 2016

Works for me with minor modifications (by deleting all the while loops). Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment