Re: Images in Conky (specifically rhythmbox album art)

I modded the script below so it will only download and save ~/.album if the artist and album title have changed since the last time you $excei this script.  for those who use $execi so you can refresh your currently playing song and cover art.  without this mod you'll download the same cover repeatedly putting unneeded strain on your network and system resources.  Also note, that my conkyrc uses ${if_running rhythmbox} so it wont load it on startup.

#!/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}

this is what it looks like:
http://img81.imageshack.us/img81/451/clipa.png

save this image as "~/.notplaying" so you have something to show when there's nothing playing or rhythmbox is shutdown.
http://img248.imageshack.us/img248/4944/notplayingcopy.png

name this in ".getcover" in "~/bin/"

#!/bin/bash +x
artist=`rhythmbox-client --print-playing-format %ta`
album=`rhythmbox-client --print-playing-format %at`
lastfetch=`cat ~/.covercheck | grep "$artist $album"`
if [[ $lastfetch == "$artist $album" ]]; then
exit 1
else
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 ~/.album
echo "$artist $album" > ~/.covercheck
fi

heres my RC file

##    System interaction
double_buffer yes
text_buffer_size 512
update_interval 1

##    Font setup
use_xft yes
xftfont Bitstream Sans:size=10
default_color 000000
uppercase no
draw_shades no

##    Window setup
alignment bottom_left
maximum_width 500
minimum_size 300 100
own_window yes
own_window_transparent yes
own_window_type override # Try also 'normal' or 'override'
gap_x 5
gap_y 5


TEXT
${voffset -35}${image ~/.notplaying -p 0,2 -s 100x100 -f 30}
${if_running rhythmbox}
${if_match "${exec rhythmbox-client --print-playing-format %tt}" == "Not playing"}
${voffset -35}${image ~/.notplaying -p 0,2 -s 100x100 -f 30}
${offset 105}No Track
$else
${execi 15 ~/bin/getcover}
${voffset -50}${image ~/.album -p 0,2 -s 100x100 -f 30}
${offset 105}$color${execi 30 rhythmbox-client --print-playing-format %tt}
${offset 105}$color${execi 30 rhythmbox-client --print-playing-format %ta}
${offset 105}$color${execi 30 rhythmbox-client --print-playing-format %at} (${execi 30 rhythmbox-client --print-playing-format %ay})


${offset 105}$color${execi 30 rhythmbox-client --print-playing-format %te} / ${execi 30 rhythmbox-client --print-playing-format %td}$endif$endif

Re: Images in Conky (specifically rhythmbox album art)

I just quickly checked the thread, but I have not seen some for Banshee users!! tongue is there any info about it???

Statler: Are you running Mac or PC?

Waldorf: After that... I'm running away!

Re: Images in Conky (specifically rhythmbox album art)

I tried adding banshee support to mine, but I was having a lot of issues with it not reporting the track info correctly. I can give another shot at it if I have time this week.

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

Re: Images in Conky (specifically rhythmbox album art)

Well, I've finally gotten around to posting my artist-image-resize fix for iggykoopa's LastFM script to the pastebin.
http://crunchbanglinux.org/pastebin/390
Currently it only matches the width of the artist image, regardless of aspect.  I'll get around to having the script compare image width & height and resize to whichever is larger as soon as I learn how to make such comparisons in Python.

EDIT:  Also, the reflections look a little off if the image is very tall or very wide.  But that's low priority for me right now.

Last edited by pvsage (2009-11-17 06:52:49)

while ( ! ( succeed = try() ) );

Re: Images in Conky (specifically rhythmbox album art)

pvsage wrote:

I'll get around to having the script compare image width & height and resize to whichever is larger as soon as I learn how to make such comparisons in Python.

Sorted:
http://crunchbanglinux.org/pastebin/398

I cheated and looked through the existing script for an existing comparison; the script now makes the comparison and resizes the artist image to fit in the same size space as the album cover, whether the image is tall or wide.

I noticed most of you stack the images side-by-side; you could just comment out or delete everything in the size_image function from the if through the else (inclusive) and unindent the remaining four lines after the else.  The artist image will now scale to the same height as the album art, but it won't  distort into a square.  Reflections still work well with this. cool

RETRACTION:  Reflections *sorta* work.  If the artist image is wide, the right portion of the image is clipped off.  I can't think of a fix for this without creating a separate function to handle just the artist art (which may be a good idea.)  With reflections turned off, you get the full artist image no matter how wide it is.

RETRACTION 2:  The caching script has a major caveat.  If there's a temporary problem fetching art, the wrong image might get cached.  http://crunchbanglinux.org/pastebin/399 has the non-caching script with the scaling tweak, modified for height matching.

Last edited by pvsage (2009-11-19 05:15:47)

while ( ! ( succeed = try() ) );

Re: Images in Conky (specifically rhythmbox album art)

Looks good, glad your learning with it and adding some more functionality. The only thing I would change is don't import pil until you actually start working with the images. That way if your using the script just to check the album name and stuff like that it doesn't have to import pil. That's why I did a few things the way I did on it, to try and keep the imports as few as possible, the script is run pretty often and my first version of it imported a ton of stuff. It kept my netbook at like 30-40% cpu all the time.

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

Re: Images in Conky (specifically rhythmbox album art)

PIL?  We don't need no PIL!  I don't have to show you any stinkin' PIL!  lol

I removed the PIL include lines and changed the antialias function call to just Image.ANTIALIAS.  Works just fine without PIL.  PIL-free version is at http://crunchbanglinux.org/pastebin/400.

Last edited by pvsage (2009-11-19 08:05:26)

while ( ! ( succeed = try() ) );

Re: Images in Conky (specifically rhythmbox album art)

Reflections on distortion-free artist images sorted.
http://crunchbanglinux.org/pastebin/401
http://omploader.org/tMnRqYg
This is the version that matches height, and should be ideal for side-by-side with artist image to the right of album art.  If anyone wants a version that matches width, longest side, or shortest side, just let me know & I'll post it/them.

Last edited by pvsage (2009-11-21 03:44:05)

while ( ! ( succeed = try() ) );

Re: Images in Conky (specifically rhythmbox album art)

I just realized that, with mocp anyway, the info call doesn't have to come from Conky.  Do other players like rhythmbox and MPD/MPC have something similar to OnSongChange that can execute a script?  Seems a waste of processor resources to have Conky constantly calling a script to check something that only changes when the song changes.

while ( ! ( succeed = try() ) );

Re: Images in Conky (specifically rhythmbox album art)

heres an onsongchange thing for mpd http://bbs.archlinux.org/viewtopic.php?id=55303 . Don't really feel like searching around for the rest, but that should give you a start. If you really wan't to minimize resource usage I would just trim down the script for the player you use. It's a little bit heavier because I wanted it to be able to support multiple players, one of the tradeoffs you pay I guess.

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

Re: Images in Conky (specifically rhythmbox album art)

^ +1  Or rewrite it to parse something like --player="mediaplayer".

I'm gunna try that pyLast I mentioned in another thread and see if I can learn enough to write a functional script for that. tongue  Apparently you have to install it first before you can see all the options; project page isn't very well documented. hmm  EDIT:  The pylast.py script itself is extremely well documented with doc strings; even I should be able to figure it out.

I might just end up making my own API.  Why not?  I already have my own key.  It would have to be something that cooperates with every media player we use around here though.

Last edited by pvsage (2009-11-23 18:30:43)

while ( ! ( succeed = try() ) );

Re: Images in Conky (specifically rhythmbox album art)

Ok...I got stuck on the first part here on the OP. I try to configure the conky 1.8 and it thinks I don't have lua5.1.

"Consider adjusting PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix"

I don't think I did that, I just installed lua5.1 from the terminal...but I guess I need to figure out where the little sucker is. Could someone tell me where to look?

Oops.

Re: Images in Conky (specifically rhythmbox album art)

Heya all

I added some code to the .py to convert the album cover to greyscale..

http://crunchbanglinux.org/pastebin/757

def grey():
    image = Image.open(home + "/.album")
    image = image.convert('L')
    image.save(home + "/.album", "png")

Original post:http://crunchbanglinux.org/forums/post/30871/#p30871
Original code:http://crunchbanglinux.org/pastebin/295

More info and screenie here: http://pieter.blinkenshell.org/blog/?p=74

Last edited by Pieter (2010-09-05 11:37:14)

Using CrunchBang 10 “Statler” Alpha 2

Re: Images in Conky (specifically rhythmbox album art)

Hello, I just started using your album art script. I really like it, I must say. Only problem is the album art doesn't change when it goes to a different album. Is that what the "imlib_cache_size 0" is for? If so could you tell me where I need to put it? Thanks in advance.

Re: Images in Conky (specifically rhythmbox album art)

What about moc?

"Of course it is happening inside your head, Harry, but why on earth should that mean that it is not real?" -Albus Dumbledore

Re: Images in Conky (specifically rhythmbox album art)

I'm using it with Rhythmbox, here's my script

${color white}Music $hr
${exec cp "`conkyRhythmbox --datatype=CA | sed -e 's/\\\//g'`" /home/diesel/.album}${image /home/diesel/.album -p 0,353 -s 64x64}
${color white}${alignr}${execi 10 rhythmbox-client --no-start --print-playing-format %tt}
${alignr}${execi 10 rhythmbox-client --no-start --print-playing-format %aa}
${alignr}${execi 10 rhythmbox-client --no-start --print-playing-format %at}

Re: Images in Conky (specifically rhythmbox album art)

@thefallofroy:  "imlib_cache_size 0" goes in your .conkyrc, pretty much anywhere above the TEXT section.

while ( ! ( succeed = try() ) );

Re: Images in Conky (specifically rhythmbox album art)

Thank you! That's what I was trying to figure out smile

Last edited by thefallofroy (2011-03-05 16:40:51)

Re: Images in Conky (specifically rhythmbox album art)

linuxfanboi wrote:

I modded the script below so it will only download and save ~/.album if the artist and album title have changed since the last time you $excei this script.  for those who use $execi so you can refresh your currently playing song and cover art.  without this mod you'll download the same cover repeatedly putting unneeded strain on your network and system resources.  Also note, that my conkyrc uses ${if_running rhythmbox} so it wont load it on startup.

#!/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}

this is what it looks like:
http://img81.imageshack.us/img81/451/clipa.png

save this image as "~/.notplaying" so you have something to show when there's nothing playing or rhythmbox is shutdown.
http://img248.imageshack.us/img248/4944/notplayingcopy.png

name this in ".getcover" in "~/bin/"

#!/bin/bash +x
artist=`rhythmbox-client --print-playing-format %ta`
album=`rhythmbox-client --print-playing-format %at`
lastfetch=`cat ~/.covercheck | grep "$artist $album"`
if [[ $lastfetch == "$artist $album" ]]; then
exit 1
else
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 ~/.album
echo "$artist $album" > ~/.covercheck
fi

heres my RC file

##    System interaction
double_buffer yes
text_buffer_size 512
update_interval 1

##    Font setup
use_xft yes
xftfont Bitstream Sans:size=10
default_color 000000
uppercase no
draw_shades no

##    Window setup
alignment bottom_left
maximum_width 500
minimum_size 300 100
own_window yes
own_window_transparent yes
own_window_type override # Try also 'normal' or 'override'
gap_x 5
gap_y 5


TEXT
${voffset -35}${image ~/.notplaying -p 0,2 -s 100x100 -f 30}
${if_running rhythmbox}
${if_match "${exec rhythmbox-client --print-playing-format %tt}" == "Not playing"}
${voffset -35}${image ~/.notplaying -p 0,2 -s 100x100 -f 30}
${offset 105}No Track
$else
${execi 15 ~/bin/getcover}
${voffset -50}${image ~/.album -p 0,2 -s 100x100 -f 30}
${offset 105}$color${execi 30 rhythmbox-client --print-playing-format %tt}
${offset 105}$color${execi 30 rhythmbox-client --print-playing-format %ta}
${offset 105}$color${execi 30 rhythmbox-client --print-playing-format %at} (${execi 30 rhythmbox-client --print-playing-format %ay})


${offset 105}$color${execi 30 rhythmbox-client --print-playing-format %te} / ${execi 30 rhythmbox-client --print-playing-format %td}$endif$endif

It works great for me, but it wont fetch a new album art when I change it in rhythmbox. Help?

Re: Images in Conky (specifically rhythmbox album art)

Nevermind, I fixed it somehow, even though I really don't know how I did it. Haha big_smile

146

Re: Images in Conky (specifically rhythmbox album art)

Hi crunchbangers,

It is quite off-board, but I wanted to share it
So, based on your scripts I wrote to put the song title and album art onto rox pinboard using rox SOAP command description.
It is also a bit different from yours as it store albumart in the album dir in order to have nice directory icons in my music dir.
As for my needs, it does only works with mocp

First a shot :
http://dl.dropbox.com/u/20498706/2011-0 … _scrot.png

next, the script:

#!/bin/bash

file=$(mocp -Q %file) 
icon=${file%/*.*}/.DirIcon
if ! [ -f "$icon" ] 
then str=`mocp -Q %a+%A | sed -e s/\ /+/g | sed -e s/\'/+/g`
url=`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="//'` 
echo $url
wget $url -q -O "$icon" 2>>~/documents/sys/log/album.log
fi
cp "${icon}" /home/ben/music/.DirIcon
rox --RPC << EOF
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
<env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
<PinboardAdd>
<Path>/home/ben/music</Path>
<Label>`mocp -Q "- %a -\n %t"`</Label>
<Update>true</Update>
</PinboardAdd>
</env:Body>
</env:Envelope>
EOF

Just have to put it as mocp song change script
Also, here is one to revert to a "standard" icon when no playing music

#!/bin/sh

cp /home/ben/music/.DirIcon.old /home/ben/music/.DirIcon
rox --RPC << EOF
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
<env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
<PinboardAdd>
<Path>/home/ben/music</Path>
<Label>Musique</Label>
<Update>true</Update>
</PinboardAdd>
</env:Body>
</env:Envelope>
EOF

Last edited by puckb (2011-03-28 20:54:21)

Re: Images in Conky (specifically rhythmbox album art)

I downloaded this version of the mpd/moc script:
http://crunchbanglinux.org/pastebin/401

I get an error: No module named Image
what do i need to install to fix this?

thanks,
tuna

Compaq Presario A900 - #! Statler Alpha2 Openbox
Privacy & Security on #! - Application List

148

Re: Images in Conky (specifically rhythmbox album art)

Tunafish wrote:

I downloaded this version of the mpd/moc script:
http://crunchbanglinux.org/pastebin/401

I get an error: No module named Image
what do i need to install to fix this?

thanks,
tuna

off hand its this commented out line,

#from PIL import Image

(line 7)
don't know why it was commented out tho.

- - - - - - - - Wiki Pages - - - - - - -
#! install guide           *autostart programs, modify the menu & keybindings
configuring Conky       *installing scripts

Re: Images in Conky (specifically rhythmbox album art)

Iggy

I'm using your script for conkymusic and it works great. I have one issue I can;t sort out though
When the artist changes the picture does get looked up and changes the .artist file in the home folder however its not changing in my conky on my desktop??
Any ideas as to why?
${execi 1 /home/joe/scripts/conkymusic.py -a -r}${image /home/joe/.artist -p 170,810}

It only changes when I restart conky.

Thanks in advance to anyone that can help

Last edited by Poisonous349 (2011-03-30 11:57:21)

Re: Images in Conky (specifically rhythmbox album art)

in your conky you need to set imlib_cache_size to 0. it is caching the image, so it doesn't change.

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