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