As I mentioned the issue in my previous post about showing media, played by MPlayer, in dzen. After some studying, learning same operations I used with char [], I have modified the code and, believe or not, I succeeded for my first attempt, complied modified code once and only. No segmentation fault or whatsoever bug, I must be lucky.

After that fix, today I decided to give it a bigger heart! I always feel that loved status is pitiful tiny (You can see it here, at bottom-right, after "Played 34 times"). At first, I thought dzen2 has ^font() to do inline font change, I believed I had read that somewhere. Obviously, my memory wasn't reliable. So I went to Open Icon Library to download this heart icon. It looks terrible:


Admittedly, I have already noticed xpm format doesn't support transparency thing. You can see the coverart somehow weird, I don't know if convert can add a background color or not. The original image is the one on the right. See that diagonal light reflection? It was gone after converting to xpm. Normal coverart won't have this problem, because they always fill image with colored pixels without alpha channel, just solid colors. But now I want to put a heart on the coverart, it becomes a problem.

So, I need to solve this. I need a method to solve this transparency issue and also be able to combine two images, coverart and heart image, together into one single image. In other term, "layered," that's the word came to my mind.

I recalled months ago, I was playing with gnuclad and happened to learn (from GNU/Linux Distribution Timeline's build script) that Inkscape can convert SVG into PNG from commandline. SVG can be used for layers. So I created a template in Inkscape and saved to plain SVG, then removed unnecessary lines, adjusted the geometry. I encountered a problem which is the coverart isn't always in perfect square shape, luckily, convert -resize 80x80 original.png resized.png can convert based on the longest side without breaking the proportion.

The key point is to avoid the transparency thing, Inkscape allows you to specify background color and that solves the issue. The final code would look like:

convert "$coverart" -resize 80x80 "$coverart_resized"
inkscape <(echo "$SVG_CONTENT") -b '$BG_COLOR' --export-png=$coverart_png
convert "$coverart_png" "$coverart_xpm"

There is a Bash tip here, I use Process Substitution so I don't need a regular SVG file on filesystem. The diff can be read on Google Code. The result is


I think it's possible to do something like reflection as you seen in iTunes in SVG. But I don't need such fancy thing. Hmm... but I am now thinking the info box is little boring. I should use SVG and render them in different fonts and colors...