3 ############################################################################
4 # soepkiptng (c) copyright 2000 Eric Lammerts <eric@lammerts.org>.
6 ############################################################################
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License, version 2, as
9 # published by the Free Software Foundation.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # A copy of the GNU General Public License is available on the World Wide Web
17 # at `http://www.gnu.org/copyleft/gpl.html'. You can also obtain it by
18 # writing to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
20 ############################################################################
30 $opt_m = "$ENV{HOME}/.mplayer.fifo";
32 # find program directory
35 my $l = readlink or die "readlink $_: $!\n";
36 if($l =~ m
|^/|) { $_ = $l; } else { s|[^/]*$|/$l|; }
39 my $progdir = abs_path
($1);
41 require "$progdir/soepkiptng.lib";
45 read_configfile
(\
%conf, $opt_c);
53 open STDIN
, "</dev/null";
54 open STDOUT
, ">/dev/null";
55 open STDERR
, ">&STDOUT";
59 sub KEY_NEXTSONG
() {163;}
60 sub KEY_PLAYPAUSE
() {164;}
61 sub KEY_PREVIOUSSONG
() {165;}
65 ($sec, $usec, $type, $code, $value) = unpack "llSSl", $event;
67 printf "%10d.%06d type=%d code=%d value%d\n", $sec, $usec, $type, $code, $value
70 next unless $type == EV_KEY
&& $value == 1;
71 printf "key %d\n", $code
74 if($code == KEY_NEXTSONG
|| $code == 90) {
75 print "kill_song();\n" if $opt_d;
77 } elsif($code == KEY_PLAYPAUSE
|| $code == 91) {
78 mplayer_cmd
("pause") || pause_toggle
();
79 } elsif($code == 116) {
88 print "pause_toggle()\n" if $opt_d;
89 open F
, $conf{statusfile
} or do {
90 warn "$conf{statusfile}: $!\n";
97 my $s = IO
::Socket
::INET
->new("$host:2222") or do {
98 warn "$host:2222: $!\n";
102 <$s>; #discard greeting
103 $s->print("pausetoggle\n");
111 sysopen M
, $opt_m, O_WRONLY
|O_NONBLOCK
123 if(opendir D
, "/dev/input") {
124 foreach(grep { /^event\d+$/ } readdir D
) {
126 if($fd{$_} = new IO
::File
"/dev/input/$_", "r") {
127 print "opened /dev/input/$_\n" if $opt_d;
128 $fd{$_}->blocking(0);
129 vec($rin,$fd{$_}->fileno(),1) = 1;
131 print "/dev/input/$_: $!\n" if $opt_d;
147 if(select($rout=$rin, undef, undef, 10)) {
149 if(vec($rout, $fd{$_}->fileno(),1)) {
151 my $r = $fd{$_}->sysread($event, 16);
152 print "read $r bytes from $_\n" if $opt_d;
154 handle_event
($event);
155 } elsif(! $!{EAGAIN
} && ! $!{EINTR
}) {