projects
/
tpope-extra.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b8bb02c
)
Added -b option to quit when on battery power
author
Tim Pope
<code@tpope.net>
Tue, 30 Nov 2004 01:09:49 +0000
(
01:09
+0000)
committer
Tim Pope
<code@tpope.net>
Tue, 30 Nov 2004 01:09:49 +0000
(
01:09
+0000)
perl/mobile-phone-monitor
patch
|
blob
|
history
diff --git
a/perl/mobile-phone-monitor
b/perl/mobile-phone-monitor
index 249f5a56087527d963c3d2e97eb557bd50746e72..535b4f67d898edd4e8e6ae4e4663bd95c6b0cf5e 100755
(executable)
--- a/
perl/mobile-phone-monitor
+++ b/
perl/mobile-phone-monitor
@@
-10,6
+10,8
@@
use strict;
use Device::Nokia;
my $number;
my %status;
use Device::Nokia;
my $number;
my %status;
+my $quiton;
+my $daemonize;
my $gsm = new Device::Nokia( port => '/dev/rfcomm1', log => 'file,/dev/null');
my $gsm = new Device::Nokia( port => '/dev/rfcomm1', log => 'file,/dev/null');
@@
-27,7
+29,12
@@
sub initialize {
initialize($gsm) || die "Could not initialize modem: $!";
initialize($gsm) || die "Could not initialize modem: $!";
-daemonize() if (shift eq "-d");
+while($_=shift) {
+ $daemonize=1 if ($_ eq "-d");
+ $quiton=1 if ($_ eq "-b");
+}
+
+daemonize() if $daemonize;
while(1) {
%status=("is_active"=>1);
while(1) {
%status=("is_active"=>1);
@@
-49,6
+56,7
@@
while($status{"is_active"} ne 0) {
}
undef $status{"number"} if (!$number && $status{"callsetup"}==0 && $status{"call"}==0);
output_status(%status);
}
undef $status{"number"} if (!$number && $status{"callsetup"}==0 && $status{"call"}==0);
output_status(%status);
+ death() if ($status{"source"}==0 && $status{"callsetup"}==0 && $status{"call"}==0 && $quiton);
}
$gsm->disconnect();
#print "Chillin'...\n";
}
$gsm->disconnect();
#print "Chillin'...\n";