| Premshree Pillai ( @ 2005-03-01 00:06:00 |
| Current music: | Beck - Lost Cause |
I’m listening to...

That’s the current song playing on my system. It’ll appear on my blog’s right. Requires XMMS bindings for Ruby and Ruby-GD (I don’t know the links to the websites.)
Ruby code »
#!/usr/local/bin/ruby # # $currsong.rb$ $2005-02-28 23:49$ # $premshree pillai$ # require 'xmms' require 'GD' require 'net/ftp' def do_current_song def ftp_image(image) ftp = Net::FTP.new($server_ftp) ftp.login($server_user, $server_pass) files = ftp.chdir($server_path) ftp.putbinaryfile(image) ftp.close end remote = Xmms::Remote.new song_title = remote.title image = GD::Image.new($image_width, $image_height) white = image.colorResolve(255,255,255) black = image.colorResolve(0,0,0) x = 0 y = 10 (err, brect) = image.stringTTF(black, $font_path, $font_size, $angle, x, y, song_title) if err puts err exit 1 end file = open($file_name, 'wb') image.png file image.destroy file.close ftp_image($file_name) end ## # required stuff ## $file_name = 'curr_song.png' # outputs this file $font_path = '/path/to/some/font' $server_ftp = 'ftp.myserver.com' $server_user = 'foo' $server_pass = 'bar' $server_path = '/path/to/dir' ## # for your pleasure ## $angle = 0 $font_size = 8.0 $image_width = 200 $image_height = 12 do_current_song
Enjoi!