allow more than one dir as argument
[soepkiptng.git] / soepkiptng_picture
blob2d109941a63efd41cd4f1ff9c9cfc90fb8c534c1
1 #!/usr/bin/perl
2 ############################################################################
3 # soepkiptng (c) copyright 2000 Eric Lammerts <eric@lammerts.org>.
4 # $Id$
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 ############################################################################
21 use Cwd 'abs_path';
22 use Getopt::Std;
24 # find program directory
25 $_ = $0;
26 while(-l) {
27 my $l = readlink or die "readlink $_: $!\n";
28 if($l =~ m|^/|) { $_ = $l; } else { s|[^/]*$|/$l|; }
30 m|(.*)/|;
31 my $progdir = abs_path($1);
33 require "$progdir/soepkiptng.lib";
35 getopts('c:');
37 read_configfile(\%conf, $opt_c);
39 $SIG{'HUP'} = sub {
40 exec $0;
41 die;
44 for(;;) {
45 my $newmtime = (stat $conf{statusfile})[9];
47 if(!$pic || -e $pic) {
48 if($newmtime == $mtime) {
49 sleep 1;
50 next;
54 open F, $conf{statusfile} or next;
55 $mtime = $newmtime;
57 my ($nowplaying, $filename);
58 chop($nowplaying = <F>);
59 chop($filename = <F>);
60 <F>;
61 $playerpid = 0 + <F>;
62 chop ((undef, undef, undef, undef,
63 $now_playing->{artist},
64 $now_playing->{title},
65 $now_playing->{album},
66 $now_playing->{track}) = <F>);
67 close F;
69 $nowplaying > 0 or next;
71 # get dir
72 $filename =~ s|/*[^/]+$||;
73 $filename =~ s|.*/|$progdir/pictures/|;
75 $pic = undef;
76 foreach(qw/gif jpg jpeg/) {
77 if(-e "$filename.$_") {
78 $pic = "$filename.$_";
79 last;
83 if($pic) {
84 system qw/xloadimage -onroot -fullscreen -border black/, $pic;
85 } else {
86 warn "$filename not found\n";
87 if($conf{picture_bg}) {
88 system qw/xloadimage -onroot -fullscreen -border black/,
89 $conf{picture_bg};
90 } else {
91 system "xsetroot -solid black";