In a previous post, I was extolling the virtues of the moosic audio server, and mentioned that I wanted to create a nice on-screen display showing what's currently playing. As it turns out, it's much easier than I hoped, thanks to two useful Perl modules: Audio::Moosic and X::Osd.
So, without further ado, here's the Perl script. I call it moosic_osd.pl, but you can call it whatever you like.
#! /usr/bin/perl -w use Audio::File; use Audio::Moosic; use X::Osd; my $osd = X::Osd->new(3); # arg means 3 lines $osd->set_font("-adobe-helvetica-medium-r-normal-*-*-100-*-*-p-*-iso8859-1"); $osd->set_colour("Red"); $osd->set_timeout(30); $osd->set_pos(XOSD_bottom); $osd->set_align(XOSD_right); $osd->set_horizontal_offset(0); $osd->set_vertical_offset(10); $osd->set_shadow_offset(1); my $moo = Audio::Moosic::Unix->new(); while (1) { my $fspec = $moo->current; if (! $fspec) { $artist = "John Lennon"; $title = "Two minutes silence"; $album = ""; } else { my $af = Audio::File->new($fspec); $artist = $af->tag->artist() || ""; $title = $af->tag->title() || ""; $album = $af->tag->album() || ""; } $osd->string(0, $title); $osd->string(1, $artist); $osd->string(2, $album); sleep(1); }
So, copy and paste that somewhere, and run it as a background job:
perl ./moosic_osd.pl &
...and you'll get a nice little on-screen display.