#!/usr/bin/perl -w

use Socket;
use DBI;

my $dbh = DBI->connect( 'dbi:mysql:dbname=lamp;host=localhost',
                        'lamp', '_password_' ) or die "$DBI::errstr";
my $meq = $dbh->prepare("update channels set username = '', now_playing = '';");
$meq->execute();

socket( CLIENT, PF_UNIX, SOCK_DGRAM, 0 ) or die;
connect( CLIENT, sockaddr_un( "/tmp/lamp-display-socket" )) or die;
select CLIENT; $|=1;

for (63 .. 75) {
    $message = pack "CC", 0, $_;
    $message .= "Available. Visit http://lamp.mit.edu to use.";
    print CLIENT $message;
    system "/usr/local/bin/lamp-randomsong $_";
}

