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 # find program directory
29 my $l = readlink or die "readlink $_: $!\n";
30 if($l =~ m
|^/|) { $_ = $l; } else { s|[^/]*$|/$l|; }
33 my $progdir = abs_path
($1);
35 require "$progdir/soepkiptng.lib";
39 read_configfile
(\
%conf, $opt_c);
41 init Gnome
"soepkiptng.pl";
43 #init Gnome::Panel::AppletWidget 'soepkiptng.pl';
73 #my $window = new Gtk::Window;
74 my $window = new Gtk
::Widget
"GtkWindow",
76 title
=> "SoepkipTNG status",
81 #$window = new Gnome::Panel::AppletWidget 'soepkiptng.pl';
84 #my $Label = Gtk::Widget->new("Gnome::CanvasText",
85 # text => "A string\nToinen rivi",
86 # font_gdk => load Gtk::Gdk::Font('-*-helvetica-*'),
87 # fill_color => 'steelblue',
91 my $label = new Gtk
::Label
("Artist\nTitle\nAlbum");
92 $label->set_justify('left');
93 #$label->set_usize(300,40);
95 my $label2 = new Gtk
::Label
("");
97 $button_pause = Gtk
::Widget
->new("GtkButton",
100 -clicked
=> sub { pause
(); },
104 $button_kill = Gtk
::Widget
->new("GtkButton",
107 -clicked
=> \
&kill_song
,
112 $hbox = new Gtk
::HBox
0, 1;
116 $vbox = new Gtk
::VBox
0, 1;
118 $hbox->pack_start($label, 0, 1, 3);
119 $hbox->pack_start($label2, 1, 1, 3);
120 $hbox->pack_start($vbox, 0, 0, 0);
122 $vbox->pack_start($button_pause, 0, 0, 1);
123 #$vbox->pack_start($button_resume, 0, 0, 1);
124 $vbox->pack_start($button_kill, 0, 0, 1);
127 #$splashimage = new Gtk::Pixmap($p,$pause_xpm)
132 my $id = Gtk
->timeout_add(1000, \
&update_song
);
134 $window->signal_connect('destroy', sub { Gtk
->exit(0); });
139 # Gnome::Panel::AppletWidget;
143 my $newmtime = (stat $conf{statusfile
})[9];
145 if($newmtime != $mtime) {
147 if(open F
, $conf{statusfile
}) {
148 my ($nowplaying, $filename);
149 chop($nowplaying = <F
>);
150 chop($filename = <F
>);
152 $playerpid = 0 + <F
>;
153 chop ((undef, undef, undef, undef,
154 $now_playing->{artist
},
155 $now_playing->{title
},
156 $now_playing->{album
},
157 $now_playing->{track
}) = <F
>);
160 if($nowplaying > 0) {
161 my $query = "SELECT song.title as title,artist.name as artist,album.name as album,song.id,song.track" .
162 " FROM song,artist,album" .
164 " AND song.artist_id=artist.id AND song.album_id=album.id";
166 if($dbh = DBI
->connect("DBI:$conf{db_type}:$conf{db_name}:$conf{db_host}", $conf{db_user
}, $conf{db_pass
})) {
167 my $sth = $dbh->prepare($query);
168 my $rv = $sth->execute($nowplaying);
169 if(my $n = $sth->fetchrow_hashref) {
175 $label->set_text(sprintf("%s\n%s\n[%02d] %s",
176 $now_playing->{artist
},
177 $now_playing->{title
},
178 $now_playing->{track
},
179 $now_playing->{album
}));
181 $filename =~ /^(.*)\/(.*?
)$/;
182 $label->set_text("$1\n$2\n");
185 $label->set_text("** soepkiptngd not running!\n\n");
190 # my $p = is_paused($playerpid);
191 # if($p != $paused) {
193 # $button_pause->set_title("Resume");
195 # $button_pause->set_title("Pause");