#!/usr/bin/env perl $beeps=$count=3; $from=80; $to=440; $step=30; for ($i = 0; $i <= $#ARGV; ++$i) { $_ = $ARGV[$i]; ARGL: { /^0$/ && exit 0; /^\d+/ && do { $count = $_; last ARGL; }; /^-nice(up|on)$/ && do { $niceup = 1; last ARGL; }; /^-nice(down|off)$/ && do { $nicedown = 1; last ARGL; }; /^-from$/ && do { $from = $ARGV[++$i]; last ARGL; }; /^-to$/ && do { $to = $ARGV[++$i]; last ARGL; }; /^-step$/ && do { $step = $ARGV[++$i]; last ARGL; }; print "usage: $0 [-niceup|-niceon] [-nicedown|-niceoff] [num_of_beeps] default number of beeps: $beeps by Slaven Rezic (eserte\@cs.tu-berlin.de), 14-05-1993 "; exit 0; } } $count = $beeps if !defined $count; eval ' sub try_x11_beep { use X11::Protocol; my $x = new X11::Protocol; die "Does not work well with VNC" if ($x->{"vendor"} =~ /AT&T Laboratories Cambridge/ || $x->{"vendor"} =~ /The Olivetti & Oracle Research Laboratory/); my %old_settings = $x->GetKeyboardControl; my $test; if ($nicedown) { ($to, $from) = ($from, $to); $step = -$step; $test = sub { $_[0] >= $to }; } else { $test = sub { $_[0] <= $to }; } for(my $pitch=$from; $test->($pitch); $pitch+=$step) { $x->ChangeKeyboardControl(bell_pitch => $pitch, bell_percent => 50); $x->Bell(10); select(undef,undef,undef,0.05); } $x->ChangeKeyboardControl(bell_percent => $old_settings{bell_percent}, bell_pitch => $old_settings{bell_pitch}, bell_duration => $old_settings{bell_duration}, ); } '; #warn $@ if $@; if ($niceup || $nicedown) { eval 'try_x11_beep()'; exit(0) if (!$@); #warn $@ if $@; $count = $beeps; } $| = 1; # flush output for($i=0; $i<$count; $i++) { print "\a"; select(undef, undef, undef, 0.2); # sleep 0.2 secs }