3 ############################################################################
4 # 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 ############################################################################
29 $opt_m = "$ENV{HOME}/.mplayer.fifo";
31 # find program directory
34 my $l = readlink or die "readlink $_: $!\n";
35 if($l =~ m
|^/|) { $_ = $l; } else { s|[^/]*$|/$l|; }
38 my $progdir = abs_path
($1);
40 require "$progdir/soepkiptng.lib";
44 read_configfile
(\
%conf, $opt_c);
52 open STDIN
, "</dev/null";
53 open STDOUT
, ">/dev/null";
54 open STDERR
, ">&STDOUT";
58 sub KEY_NEXTSONG
() {163;}
59 sub KEY_PLAYPAUSE
() {164;}
60 sub KEY_PREVIOUSSONG
() {165;}
64 ($sec, $usec, $type, $code, $value) = unpack "llSSl", $event;
66 printf "%10d.%06d type=%d code=%d value%d\n", $sec, $usec, $type, $code, $value
69 next unless $type == EV_KEY
&& $value == 1;
70 printf "key %d\n", $code
73 if($code == KEY_NEXTSONG
|| $code == 90) {
74 print "kill_song();\n" if $opt_d;
76 } elsif($code == KEY_PLAYPAUSE
|| $code == 91) {
77 mplayer_cmd
("pause") || pause_toggle
();
78 } elsif($code == 116) {
87 print "pause_toggle()\n" if $opt_d;
88 open F
, $conf{statusfile
} or do {
89 warn "$conf{statusfile}: $!\n";
96 my $s = IO
::Socket
::INET
->new("$host:2222") or do {
97 warn "$host:2222: $!\n";
101 <$s>; #discard greeting
102 $s->print("pausetoggle\n");
110 sysopen M
, $opt_m, O_WRONLY
|O_NONBLOCK
122 if(opendir D
, "/dev/input") {
123 foreach(grep { /^event\d+$/ } readdir D
) {
125 if($fd{$_} = new IO
::File
"/dev/input/$_", "r") {
126 print "opened /dev/input/$_\n" if $opt_d;
127 $fd{$_}->blocking(0);
128 vec($rin,$fd{$_}->fileno(),1) = 1;
130 print "/dev/input/$_: $!\n" if $opt_d;
146 if(select($rout=$rin, undef, undef, 10)) {
148 if(vec($rout, $fd{$_}->fileno(),1)) {
150 my $r = $fd{$_}->sysread($event, 16);
151 print "read $r bytes from $_\n" if $opt_d;
153 handle_event
($event);
154 } elsif(! $!{EAGAIN
} && ! $!{EINTR
}) {