SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2009-07-25 21:08:54

aslamp
Member
Registered: 2009-07-20
Posts: 25

Images in Conky (specifically rhythmbox album art)

i've been looking for this for a while, and thought others might be too, so i thought i'd give a quick run down on what i'm doing.

24no7s4.jpg

pretty, i know wink

alright, first off, you gotta grab the conky source (http://sourceforge.net/projects/conky/files/), then extract it, ./configure it, with "--enable-imlib2" (source), then make and install it.

from there, install conkyRhythmbox by kaivalagi from this post (it has the album art option in it)

once everything's set, stick something like this in your .conkyrc:

${offset 69}${font AvantGardeLTMedium:size=10}${exec rhythmbox-client --print-playing-format %tt}
${offset 69}$color1${exec rhythmbox-client --print-playing-format %ta}$font${exec ret}
${exec cp "`conkyRhythmbox --datatype=CA | sed -e 's/\\\//g'`" /home/jack/.album}${image /home/jack/.album -p 0,2 -s 64x64}

the last line is the important stuff. it copies the cached album art that rhythmbox uses to a static file that conky loads with the $image tag. you'll probably wanna stick in an "imlib_cache_size 0" in there as well so it doesn't cache the file.

this can work with any player really, as long as you can find the current song's album art location.

special thanks to kaivalagi and whoever did the conky.wikia page.

hope you find it useful.

Offline

Help fund CrunchBang, donate to the project!

#2 2009-07-25 21:45:19

omns
#! wanderer
From: ~/
Registered: 2008-11-25
Posts: 5,131

Re: Images in Conky (specifically rhythmbox album art)

Wow, that looks great. Thanks for sharing smile

Offline

#3 2009-07-25 23:07:31

gogi-goji
#! CrunchBanger
From: Canada
Registered: 2009-07-25
Posts: 128
Website

Re: Images in Conky (specifically rhythmbox album art)

Would it be possible to modify the code to grab the album art from the internet?  I think that would make it even better.


My blog

Offline

#4 2009-07-25 23:11:09

aslamp
Member
Registered: 2009-07-20
Posts: 25

Re: Images in Conky (specifically rhythmbox album art)

some sort online album art repository would make it pretty easy to write something to fetch it. otherwise, might be tricky.

if you know of any good places, let me know, and i'll figure something out.

Offline

#5 2009-07-25 23:54:16

corenominal
WRONG
From: Lincoln, UK
Registered: 2008-11-20
Posts: 5,057
Website

Re: Images in Conky (specifically rhythmbox album art)

^^ http://www.albumart.org/ might be of use?

Offline

#6 2009-07-26 00:47:02

aslamp
Member
Registered: 2009-07-20
Posts: 25

Re: Images in Conky (specifically rhythmbox album art)

@corenominal perfect!
qn7k0l.jpg
alright, so this is what i worked up.

#!/bin/bash
artist=`rhythmbox-client --print-playing-format %ta`
album=`rhythmbox-client --print-playing-format %aa`
str="`echo "$artist $album" | sed -e s/\\ /+/g`"
wget `wget "http://www.albumart.org/index.php?srchkey=$str&itempage=1&newsearch=1&searchindex=Music" -q -O - | 
grep "http://www.albumart.org/images/zoom-icon.jpg" -m 1 | 
sed -e 's/" border="0" class="image_border.*//' |
sed -e 's/.*img src="//'` -q -O /home/jack/.album

i called it albumart, gave it a chmod +x, then stuck it in ~/bin , then put this in conkyrc

${exec albumart}${image /home/jack/.album -p 0,110 -s 64x64}

I'm not sure what happens if there isn't one found. it might explode.

but it basically searches for the artist and album, then displays the first image found. it's not that big, but i works for me.

lemme know if something doesn't work tongue

Last edited by aslamp (2009-07-26 00:51:19)

Offline

#7 2009-07-26 01:05:11

corenominal
WRONG
From: Lincoln, UK
Registered: 2008-11-20
Posts: 5,057
Website

Re: Images in Conky (specifically rhythmbox album art)

Nice work! Thank you for sharing. smile

aslamp wrote:

I'm not sure what happens if there isn't one found. it might explode.

I would not worry, that event is clearly covered in CrunchBang's disclaimer. big_smile

Offline

#8 2009-07-26 01:06:45

gogi-goji
#! CrunchBanger
From: Canada
Registered: 2009-07-25
Posts: 128
Website

Re: Images in Conky (specifically rhythmbox album art)

Brilliant, thanks!  I'll test it out now.


My blog

Offline

#9 2009-07-26 03:19:23

gogi-goji
#! CrunchBanger
From: Canada
Registered: 2009-07-25
Posts: 128
Website

Re: Images in Conky (specifically rhythmbox album art)

I had to do a very slight modification of the script.  I use moc as my media player, but it was simple enough to change the script to get the information from moc.

artist=`mocp -Q %artist`
album=`mocp -Q %album`

I left the rest of the album art fetcher script untouched. 

In my .conkyrc file, I am using

${exec bash /home/cam/.moc/moc-albumart.sh}${image /home/cam/.album -p 0,425 -s 64x64}

to call up the image.  The file on my hard drive, ~/.album, updates upon changing album.  However, conky does not update the image, and as a side effect of the script running, only updates every 3-4 seconds instead of every second.  I'm unsure as to how to change this.  Perhaps change the script to first check if the image is different?  I might also see if I can get moc to execute the album art fetcher upon song change.

In case there is no album art found, would it be possible to have wget, upon returning an error and not being able to fetch a file, delete the ~/.album file?  Unfortunately, I don't know how to do this myself (due to my lack of knowledge about any kind of programming or scripting).


My blog

Offline

#10 2009-07-26 07:25:30

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,485

Re: Images in Conky (specifically rhythmbox album art)

you'll need to change the exec statement to execi if you want it to update. Exec just runs once on conky startup.


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#11 2009-08-01 04:44:49

johnpriest
New Member
Registered: 2009-08-01
Posts: 4

Re: Images in Conky (specifically rhythmbox album art)

aslamp wrote:

i've been looking for this for a while, and thought others might be too, so i thought i'd give a quick run down on what i'm doing.

24no7s4.jpg

pretty, i know wink

alright, first off, you gotta grab the conky source (http://sourceforge.net/projects/conky/files/), then extract it, ./configure it, with "--enable-imlib2" (source), then make and install it.

from there, install conkyRhythmbox by kaivalagi from this post (it has the album art option in it)

once everything's set, stick something like this in your .conkyrc:

${offset 69}${font AvantGardeLTMedium:size=10}${exec rhythmbox-client --print-playing-format %tt}
${offset 69}$color1${exec rhythmbox-client --print-playing-format %ta}$font${exec ret}
${exec cp "`conkyRhythmbox --datatype=CA | sed -e 's/\\\//g'`" /home/jack/.album}${image /home/jack/.album -p 0,2 -s 64x64}

the last line is the important stuff. it copies the cached album art that rhythmbox uses to a static file that conky loads with the $image tag. you'll probably wanna stick in an "imlib_cache_size 0" in there as well so it doesn't cache the file.

this can work with any player really, as long as you can find the current song's album art location.

special thanks to kaivalagi and whoever did the conky.wikia page.

hope you find it useful.

would it be possible to grab your entire conky config files? I rather like yours from the screenshot.

Offline

#12 2009-08-01 18:06:40

aslamp
Member
Registered: 2009-07-20
Posts: 25

Re: Images in Conky (specifically rhythmbox album art)

This is the second screenshot (the whiteish one). I don't have the brown one anymore, but if you can't figure anything out from this one to change it, let me know!

It uses a gmail script, conkyGoogleReader and conkyForecast

background yes
use_xft yes
xftfont AvantGardeLTMedium:size=8
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent yes
own_window_type desktop
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 200 200
draw_shades yes
draw_outline no
draw_borders no
draw_graph_borders no
default_shade_color black
default_outline_color white
default_bar_size 20 20
default_gauge_size 20 20
imlib_cache_size 0


default_color D7D3C5
color1 9f907d

default_color 444444
color1 888888

draw_shades no

alignment bottom_left
gap_x 5
gap_y 0
no_buffers yes
uppercase yes
cpu_avg_samples 2
override_utf8_locale no

TEXT


${offset 69}${font AvantGardeLTMedium:size=10}${exec rhythmbox-client --print-playing-format %tt}
${offset 69}$color1${exec rhythmbox-client --print-playing-format %ta}$font${exec ret}
${execi 1 albumart}${image /home/jack/.album -p 0,0 -s 64x64}
      $color${execi 30 python ~/bin/gmail.py}$color1 new messages
      $color${execi 30 python ~/bin/conkyGoogleReader.py --username=gmail --password=password}$color1 unread items
${image /home/jack/images/gr -p 0,91 -s 16x16}${image /home/jack/images/gm -p 1,77 -s 14x14}
${color1}Uptime $color$uptime
${color1}Root $color${fs_free /} Free
${color1}home $color${fs_free /media/home/} Free
${color1}CPU $color${cpu cpu0}% / ${cpu cpu1}%
${color1}RAM $color$memfree Free

$color1${execi 60 conkyForecast -l USIN0211 -d CC} $color${execi 60 conkyForecast -l USIN0211 -d HT -i -u -x -e 3}F 
$color${font AvantGardeLTMedium:size=24}${time %l:%M} $font$color1${Time %a %d %b}

gmail.py:

import os
import string

#Enter your username and password below within double quotes
# eg. username="username" and password="password"
username=""
password=""

com="wget -O - https://"+username+":"+password+"@mail.google.com/mail/feed/atom --no-check-certificate"

temp=os.popen(com)
msg=temp.read()
index=string.find(msg,"<fullcount>")
index2=string.find(msg,"</fullcount>")
fc=int(msg[index+11:index2])

if fc==0:
   print "0"
else:
   print str(fc)

Offline

#13 2009-08-01 18:16:31

geoisis
Member
Registered: 2009-08-01
Posts: 17

Re: Images in Conky (specifically rhythmbox album art)

this is awesome big_smile
could you help me, make this work for sonata/mpd ?

Offline

#14 2009-08-01 19:09:11

aslamp
Member
Registered: 2009-07-20
Posts: 25

Re: Images in Conky (specifically rhythmbox album art)

I'm actually trying to make the switch over to that right now

i'll post when i get it pretty =]

Offline

#15 2009-08-01 19:19:06

geoisis
Member
Registered: 2009-08-01
Posts: 17

Re: Images in Conky (specifically rhythmbox album art)

big_smile that's good news
i've found a script over at archlinux, that shows the albumart from the .covers folder that sonata uses, but i want see if there is a way to put your fetching script too, so it downloads the covers from the net.

goodluck smile

Offline

#16 2009-08-01 21:52:46

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,485

Re: Images in Conky (specifically rhythmbox album art)

here you go:

#!/usr/bin/python

import os,commands, urllib

home = os.getenv("HOME")
artist=commands.getoutput("mocp -Q %artist").replace(" ", "+")
album=commands.getoutput("mocp -Q %album").replace(" ", "+")
if artist == "" and album == "":
    if os.path.exists(home + "/.album"):
        os.remove(home + "/.album")
else:
    url = "http://www.albumart.org/index.php?srchkey=" + artist + "+" + album + "&itempage=1&newsearch=1&searchindex=Music"
    albumart = urllib.urlopen(url).read()
    image = ""
    for line in albumart.split("\n"):
        if "http://www.albumart.org/images/zoom-icon.jpg" in line:
            image = line.partition('src="')[2].partition('"')[0]
            break
    if image:
        if os.path.exists("/tmp/imagepath"):
            imagepath = open("/tmp/imagepath").read()
            if imagepath == image:
                pass
            else:
                urllib.urlretrieve(image, home + "/.album")
        else:
            urllib.urlretrieve(image, home + "/.album")
        open("/tmp/imagepath","w").write(image)
    else:
        if os.path.exists(home + "/.album"):
            os.remove(home + "/.album")

should now delete the album if it can't find one. If anyone can think of improvements let me know.

edit: forgot to mention that its setup for moc since thats what I use. I may change it later to support other players with a command line switch, but for now you should be able to figure out how to change the artist and album line.

edit: modified it so it doesn't redownload the album art every couple seconds.


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#17 2009-08-01 22:45:56

geoisis
Member
Registered: 2009-08-01
Posts: 17

Re: Images in Conky (specifically rhythmbox album art)

Traceback (most recent call last):
  File "/home/geo/test.py", line 15, in <module>
    albumart = urllib.urlopen(url).read()
  File "/usr/lib/python2.6/urllib.py", line 87, in urlopen
    return opener.open(url)
  File "/usr/lib/python2.6/urllib.py", line 203, in open
    return getattr(self, name)(url)
  File "/usr/lib/python2.6/urllib.py", line 318, in open_http
    if not host: raise IOError, ('http error', 'no host given')
i get this error

Offline

#18 2009-08-01 22:50:59

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,485

Re: Images in Conky (specifically rhythmbox album art)

hmmm that's weird, I've tried it with moc not running and it just returns nothing, no error though. what song were you playing at the time? Are you using moc?

edit: fixed one bug in it, if you play a song with no album cover then play another song from the last album you played it wont redownload the cover....heres the fix

#!/usr/bin/python

import os,commands, urllib

home = os.getenv("HOME")
artist=commands.getoutput("mocp -Q %artist").replace(" ", "+")
album=commands.getoutput("mocp -Q %album").replace(" ", "+")
if artist == "" and album == "":
    if os.path.exists(home + "/.album"):
        os.remove(home + "/.album")
else:
    url = "http://www.albumart.org/index.php?srchkey=" + artist + "+" + album + "&itempage=1&newsearch=1&searchindex=Music"
    albumart = urllib.urlopen(url).read()
    image = ""
    for line in albumart.split("\n"):
        if "http://www.albumart.org/images/zoom-icon.jpg" in line:
            image = line.partition('src="')[2].partition('"')[0]
            break
    if image:
        if os.path.exists("/tmp/imagepath") and os.path.exists(home + "/.album"):
            imagepath = open("/tmp/imagepath").read()
            if imagepath == image:
                pass
            else:
                urllib.urlretrieve(image, home + "/.album")
        else:
            urllib.urlretrieve(image, home + "/.album")
        open("/tmp/imagepath","w").write(image)
    else:
        if os.path.exists(home + "/.album"):
            os.remove(home + "/.album")

I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#19 2009-08-02 00:08:33

geoisis
Member
Registered: 2009-08-01
Posts: 17

Re: Images in Conky (specifically rhythmbox album art)

hi again

i've used both mocp and sonata/mpc and i get the same error
but i think the error is caused by python
meaning i've changed

 albumart = urllib.urlopen(url).read()

with

albumart = urllib2.urlopen(url).read()

and i got rid of that error but i still have some issues.

strange...hmmm now it works alright with urllib, but no album art shows up, at least i get no errors regarding the code

again edit tongue

got it now smile i had some wrong in conky

and as for mpd, you can put this

artist=commands.getoutput("mpc --format %artist% | head -n 1").replace(" ", "+")
album=commands.getoutput("mpc --format %album% | head -n 1").replace(" ", "+")


thank you smile

Last edited by geoisis (2009-08-02 00:36:46)

Offline

#20 2009-08-02 03:37:28

johnpriest
New Member
Registered: 2009-08-01
Posts: 4

Re: Images in Conky (specifically rhythmbox album art)

aslamp wrote:

This is the second screenshot (the whiteish one). I don't have the brown one anymore, but if you can't figure anything out from this one to change it, let me know!

It uses a gmail script, conkyGoogleReader and conkyForecast

background yes
use_xft yes
xftfont AvantGardeLTMedium:size=8
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent yes
own_window_type desktop
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 200 200
draw_shades yes
draw_outline no
draw_borders no
draw_graph_borders no
default_shade_color black
default_outline_color white
default_bar_size 20 20
default_gauge_size 20 20
imlib_cache_size 0


default_color D7D3C5
color1 9f907d

default_color 444444
color1 888888

draw_shades no

alignment bottom_left
gap_x 5
gap_y 0
no_buffers yes
uppercase yes
cpu_avg_samples 2
override_utf8_locale no

TEXT


${offset 69}${font AvantGardeLTMedium:size=10}${exec rhythmbox-client --print-playing-format %tt}
${offset 69}$color1${exec rhythmbox-client --print-playing-format %ta}$font${exec ret}
${execi 1 albumart}${image /home/jack/.album -p 0,0 -s 64x64}
      $color${execi 30 python ~/bin/gmail.py}$color1 new messages
      $color${execi 30 python ~/bin/conkyGoogleReader.py --username=gmail --password=password}$color1 unread items
${image /home/jack/images/gr -p 0,91 -s 16x16}${image /home/jack/images/gm -p 1,77 -s 14x14}
${color1}Uptime $color$uptime
${color1}Root $color${fs_free /} Free
${color1}home $color${fs_free /media/home/} Free
${color1}CPU $color${cpu cpu0}% / ${cpu cpu1}%
${color1}RAM $color$memfree Free

$color1${execi 60 conkyForecast -l USIN0211 -d CC} $color${execi 60 conkyForecast -l USIN0211 -d HT -i -u -x -e 3}F 
$color${font AvantGardeLTMedium:size=24}${time %l:%M} $font$color1${Time %a %d %b}

gmail.py:

import os
import string

#Enter your username and password below within double quotes
# eg. username="username" and password="password"
username=""
password=""

com="wget -O - https://"+username+":"+password+"@mail.google.com/mail/feed/atom --no-check-certificate"

temp=os.popen(com)
msg=temp.read()
index=string.find(msg,"<fullcount>")
index2=string.find(msg,"</fullcount>")
fc=int(msg[index+11:index2])

if fc==0:
   print "0"
else:
   print str(fc)

amazing, thank you very much ^^ gotta love the linux community and the sharing ^^

Offline

#21 2009-08-02 07:37:12

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,485

Re: Images in Conky (specifically rhythmbox album art)

glad it's working for you geoisis, that's weird that it works for me with just urllib and you have to change it to urllib2. Oh well as long as it works.


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#22 2009-08-02 16:49:21

geoisis
Member
Registered: 2009-08-01
Posts: 17

Re: Images in Conky (specifically rhythmbox album art)

it works with urllib also now smile.
also i was thinking, fetching album covers from last.fm and also artist image smile, but my knowledge is not so good with python.

Offline

#23 2009-08-02 16:53:08

Hanna
Conky Queen
From: Finland
Registered: 2008-11-29
Posts: 759

Re: Images in Conky (specifically rhythmbox album art)

What would be the best way to get album art in conky, if you are using QuodLibet?


HANNA (without "h" in the end) likes green and #! smile
Also know as ultraturquoise online / #! last.fm / #! DeviantART / U

Offline

#24 2009-08-02 17:55:44

geoisis
Member
Registered: 2009-08-01
Posts: 17

Re: Images in Conky (specifically rhythmbox album art)

http://code.google.com/p/python-lastfm/ found this big_smile. python to work with the last.fm API.

Offline

Be excellent to each other!

#25 2009-08-02 18:34:22

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,485

Re: Images in Conky (specifically rhythmbox album art)

heres http://crunchbanglinux.org/pastebin/291 a new copy that makes it look nice and add's the artist, title, and album to the picture. Heres a screenshot:
2r547sy.png
just need to find a font that looks a little better.

edit: forgot to mention you need to save this http://ecx.images-amazon.com/images/I/11J2DMYABHL.jpg image as .noalbum in your home folder. If it can't find an album this is the one it uses.

edit again: fixed a bug in it, the pastebin is updated now

last edit: would everyone like me to switch over to last.fm? theres a lot more info easily searchable...but you would have to get an api key


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo