summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/ekgping22
1 files changed, 21 insertions, 1 deletions
diff --git a/bin/ekgping b/bin/ekgping
index 020b1f0..f01dd32 100755
--- a/bin/ekgping
+++ b/bin/ekgping
@@ -5,7 +5,8 @@ use warnings;
use 5.010;
use IO::Handle;
-use IPC::Run qw(harness);
+use IPC::Run qw(harness io);
+use File::Slurp qw(write_file);
use Term::Size;
use Time::HiRes qw(usleep);
@@ -21,12 +22,19 @@ my $dead_count = 0;
my $column = 0;
my $column_max = ( Term::Size::chars * STDOUT { IO } )[0];
+my $sin = q{};
+my $in;
+
my $ping = harness(
[ 'ping', '-n', $host ],
'<' => \undef,
'>&' => \&parse_ping_output,
);
+my $beep_harness = harness(
+ io( '/dev/audio', '<', \$in ),
+);
+
local $SIG{TERM} = \&quit;
local $SIG{INT} = \&quit;
@@ -55,7 +63,14 @@ sub quit {
exit 0;
}
+for ( 1 .. 50 ) {
+ for my $i ( 0 .. 19, 18 .. 1 ) {
+ $sin .= chr( ( sin($i) + 1 ) * 126 );
+ }
+}
+
$ping->start();
+$beep_harness->start();
# Ignore first line
$ping->pump();
@@ -97,6 +112,11 @@ while ( usleep(100_000) ) {
}
STDOUT->flush();
+
+ if ($beep) {
+ $in = $sin;
+ $beep_harness->pump_nb();
+ }
}
$ping->kill_kill( grace => 1 );