blog updates

I’ve added a few more bits and pieces to the site here, most notably the weather and ‘now playing’ bits on the right.

The weather applet is called WeatherIcon and i’ve got it set to use a set of icons supposedly similar to those found within MacOSX… granted, the dark background makes it look like permenant night-time, but it matches this site slightly better than the other icon sets. The output was modified slightly to make it fit and look right on the sidebar there.

Amarok is an open-source music player mostly written for KDE, but i’m using it in Gnome just fine. I added a script to it called – surprisingly enough – amarokNowPlaying. This script is designed to grab the status and details of whatever song is playing, with cover art if available, and create an image out of it for use on websites n stuff… you’ve probably seen many sites with similar pics produced by winamp. It didn’t quite suit my purposes without some hax0ring of the script, so now i’ve also got it uploading just the text info of the song to my website along with a re-sized png image of the cd cover. I had to install the ‘ftp-upload’ binary to my local pc so it uploaded properly, so here are the changes for people that are interested in such things (and also for people wanting to know how to create a translucent png using ‘convert’… god that took a while for me to figure out!)

convert -resize 40x40 -type TrueColorMatte -channel alpha -evaluate multiply 0.5 /local/cover.jpg /local/cover.png
ftp-upload -h my.server.com -u username --password password -d destination/dir /local/nowPlaying.txt /local/cover.png

Oh and here’s how I did the website code:
$amarokfile = fopen("/dir/nowPlaying.txt", "r");
$playing = 'true';
while ($theData = fgets($amarokfile))
{
if (strstr($theData, "status: 0"))
$playing = 'false';
if ($playing == 'true')
{
if (substr($theData, 0, 6) == 'artist')
{
$artist = substr($theData, 8);
if (substr(nl2br($artist), 0, 4) == "<br ")
{
$not_artist = 1;
}
}
if ($not_artist == 1)
{
if (substr($theData, 0, 5) == 'album')
{
$artist = substr($theData, 7);
}
}
if (substr($theData, 0, 5) == 'title')
$title = substr($theData, 7);
if (substr($theData, 0, 6) == 'length')
$length = substr($theData, 8);
}
}

And to output it to the page:
if ($playing == 'true')
{
echo "<p style='background-image: url(/cover.png); background-repeat: no-repeat; background-position: center right;'><u>Now playing in my Amarok</u><br>";
if ($not_artist == 1)
echo 'Stream: ';
else
echo 'Artist: ';
echo "<font class='amarok'>$artist</font><br>Title: <font class='amarok'>$title</font>";
if ($not_artist != 1)
echo "<br>Length: <font class='amarok'>$length</font></p>";
}
else
{
echo "<p><u>Now playing in Amarok</u><br><font class='amarok'>Nothing</font>";
}

Post to Twitter

Leave a Reply