2 ############################################################################
3 # soepkiptng (c) copyright 2000 Eric Lammerts <eric@lammerts.org>.
5 ############################################################################
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License, version 2, as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # A copy of the GNU General Public License is available on the World Wide Web
16 # at `http://www.gnu.org/copyleft/gpl.html'. You can also obtain it by
17 # writing to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 # Boston, MA 02111-1307, USA.
19 ############################################################################
26 use POSIX
":sys_wait_h";
28 # find program directory
31 my $l = readlink or die "readlink $_: $!\n";
32 if($l =~ m
|^/|) { $_ = $l; } else { s|[^/]*$|/$l|; }
35 my $progdir = abs_path
($1);
37 require "$progdir/soepkiptng.lib";
41 read_configfile
(\
%conf, $opt_c);
43 $dbh = DBI
->connect("DBI:$conf{db_type}:$conf{db_name}:$conf{db_host}",
44 $conf{db_user
}, $conf{db_pass
}) or die "can't connect to database";
47 open STDOUT
, ">/dev/null";
49 while(waitpid(-1,WNOHANG
) > 0) {
54 while((stat $conf{statusfile
})[9] == $mtime) { sleep 1; }
56 if($pid) { kill 9, $pid; wait; }
57 print STDERR
"\n"x100
;
58 open F
, $conf{statusfile
} or next;
62 ($lyrics, $ar, $ti, $al, $tr) = $dbh->selectrow_array(
63 "SELECT lyrics.lyrics, artist.name, song.title, album.name, song.track " .
65 "LEFT JOIN album ON album.id=song.album_id " .
66 "LEFT JOIN artist ON artist.id=song.artist_id " .
67 "LEFT JOIN lyrics ON lyrics.id=song.id " .
72 if(($pid = fork) == 0) {
73 open STDOUT
, ">/dev/tty";
78 $t = "$ar - $ti ($al [$tr])";
80 print "-" x
length($t);
81 print "\n\n$lyrics\n";