own_window yes own_window_type desktop own_window_class Conky own_window_transparent true own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager out_to_console no out_to_stderr no double_buffer yes use_xft yes xftfont Monospace:size=8 update_interval 1 total_run_times 0 maximum_width 400 minimum_size 400 imlib_cache_size 100 background yes draw_borders no draw_graph_borders yes draw_outline no draw_shades no stippled_borders 1 border_inner_margin 5 border_outer_margin 10 border_width 1 default_color white default_outline_color white default_shade_color black alignment bl show_graph_scale no show_graph_range no gap_x 20 gap_y 20 no_buffers yes uppercase no cpu_avg_samples 2 net_avg_samples 2 override_utf8_locale yes use_spacer none TEXT ${if_mpd_playing}${execi 5 ~/.themes/conky/mpd-cover}${image /tmp/mpd-track-cover.jpg -s 50x50}${offset 55}${mpd_artist} - ${mpd_title} ${offset 55}${mpd_album} ${offset 55}${mpd_bar} ${offset 55}${mpd_elapsed}/${mpd_length}${endif} ----------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------- #!/usr/bin/python2 import os import shutil import commands import urllib # Path where the images are saved imgpath = "/home/dmitri/.covers/" # Path where 'artist-only' images can be found artistimgpath = "/home/dmitri/.covers/" # Image displayed when no image found noimg = "/home/dmitri/.covers/nocover.png" # Cover displayed by conky cover = "/tmp/mpd-track-cover.jpg" def copycover(currentalbum, src, artistsrc, dest, defaultfile): searchstring = currentalbum.replace(" ", "+") if not os.path.exists(src): url = "http://www.albumart.org/index.php?srchkey=" + searchstring + "&itempage=1&newsearch=1&searchindex=Music" cover = urllib.urlopen(url).read() image = "" for line in cover.split("\n"): if "http://www.albumart.org/images/zoom-icon.jpg" in line: image = line.partition('src="')[2].partition('"')[0] break if image: urllib.urlretrieve(image, src) if os.path.exists(src): shutil.copy(src, dest) elif os.path.exists(artistsrc): shutil.copy(artistsrc, dest) elif os.path.exists(defaultfile): shutil.copy(defaultfile, dest) else: print "" # Name of current album album = commands.getoutput("mpc --format %artist%-%album% | head -n 1") artist = commands.getoutput("mpc --format %artist% | head -n 1") # If tags are empty, use noimg. # Hieronder stond steeds conkycover ipv cover, heb ik gewijzigd. if album == "": if os.path.exists(cover): os.remove(cover) if os.path.exists(noimg): shutil.copy(noimg, cover) else: print "" else: filename = imgpath + album + ".jpg" artistfilename = artistimgpath + artist + ".jpg" if os.path.exists("/tmp/mpd-now-playing") and os.path.exists("/tmp/mpd-track-cover.jpg"): nowplaying = open("/tmp/mpd-now-playing").read() if nowplaying == album: pass else: copycover(album, filename, artistfilename, cover, noimg) open("/tmp/mpd-now-playing", "w").write(album) else: copycover(album, filename, artistfilename, cover, noimg) open("/tmp/mpd-now-playing", "w").write(album)