Displaying the now playing track from Spotify in Conky

Mar 14, 2011 01:10

The big problem is how to get the information, using xwininfo it is possible to get the information from the window title.

e.g.
xwininfo -root -children | grep spotify

will give an output string along the lines of
0x3200005 "Spotify - Manowar - Kings Of Metal": ("spotify.exe" "Wine") 1550x800+0+0 +0+0

the next issue is to extract the artist and song from the string, I have two approaches to this...

One
xwininfo -root -children | grep spotify | cut -d\" -f2 | cut -c 10-

Two
xwininfo -root -children | grep spotify | perl -lne 'print $1 if /Spotify\ \-\ (.*)":/;'

(Gratitude goes to dbbolton for help with the pattern matching)

both of which will output a string along the lines of
Manowar - Kings Of Metal

now all one has to do is use Conkys execi command to execute the code :-D

conky, geek, spotify, linux, debian

Previous post Next post
Up