TGI's node was (dare I say) brilliant. That one could potentially use a Beowulf cluster to time an egg, and particularly that one could do it with Perl, brought a tear to the eye of this old crusty.

However, it got me thinking. What if I'm timing an 18 pound turkey, and I've got to pop on in to work for a bit. I've got to know when it's time to come out of the oven.

And the sound of chr(0x07) is, well, a bit grating.

There was just too much potential here to waste.

So I present to you the Super-Deluxe Egg Timer (TM). It uses Net::Peep to broadcast any of a variety of soothing bird calls, from a hermit thrush to a robin to a mourning dove to a redwing blackbird, to any server running Peep.

Enjoy :-)

P.S. If you like this node, please throw a vote the way of this node too since TGI thought of the idea first.

#!/usr/bin/perl =head1 NAME egg-timer - A super-deluxe egg timer using Net::Peep. =head1 DESCRIPTION It is an egg timer. What more do you want? =head1 CONFIGURATION To use this client, include a section like the following in the events block of peep.conf: events #Event Type | Path to Sound File | # of sounds to + load ... timer /usr/local/share/peep/sounds/wetlands/events/hermit-thrush-01 +.* 1 end events =head1 USAGE ./egg-timer --help ./egg-timer --server=www.foo.org --port=2126 \ --sound=timer --wait=60 ./egg-timer --wait=300 The --sound and --wait options are specific to this client. In addition, the following options are common to all Peep clients (with defaults specific to this client): --config=[PATH] Path to the configuration file to use. --debug=[NUMBER] Enable debugging. (Def: 0) --nodaemon Do not run in daemon mode. (Default) --pidfile=[PATH] The file to write the pid out to. (Daemon mod +e only.) --output=[PATH] The file to log output to. (Def: stderr) --noautodiscovery Disables autodiscovery and enables the server +and port options. (Default) --server=[HOST] The host (or IP address) to connect to. (Def: localhost) --port=[PORT NO] The port to use. (Def: 2001) --help Prints this documentation. If you have any problems, try turning on debugging output with something like --debug=9. Note that you must have the Peep daemon (peepd) running to hear the sound. You can obtain the Peep daemon at http://peep.sourceforge.net =head1 AUTHOR Collin Starkweather <collin.starkweather@colorado.edu> Copyright (C) 2 +001 =head1 SEE ALSO perl(1), peepd(1), Net::Peep, Net::Peep::Client, Net::Peep::BC =cut # Always use strict :-) use strict; use Net::Peep::BC; use Net::Peep::Client; use vars qw{ $client $conf %options $wait $sound }; # What follows is a fairly standard formula for any Peep client. The # only part you really have to define yourself is a parser method (not # applicable in this case) and a callback (see loop() below). # Basically, the meat of this client is a 4-line subroutine. $client = new Net::Peep::Client; $client->name('egg-timer'); # The options here are in Getopt::Long style. The %options hash allows # specify what event is going to be played when the timer goes off # (with --sound) and how many seconds before the timer goes off (with # --wait). $wait = 180; # default is for a 3-minute egg $sound = 'timer'; # see CONFIGURATION above my %options = ( 'wait=s' => \$wait, 'sound=s' => \$sound ); # Initialize the client object. This will parse the command line # options. The default command-line options available to all Peep # clients include --server and --port. $client->initialize(%options) || $client->pods(); # The egg timer does not need to specify a parser, so we'll feed it a # blank code reference $client->parser( sub { return; } ); # Get the Peep configuration object, which has valuable information # from the Peep configuration file and the values of any options # specified on the command-line. $conf = $client->configure(); # Make sure we default to some reasonable values. Autodiscovery # doesn't make sense for the egg timer, so we'll turn it off. The egg # timer won't be running as a daemon either. $conf->setOption('autodiscovery',0) unless $conf->optionExists('autodiscovery') and $conf->getOption('autodiscovery') == 0; $conf->setOption('server','localhost') unless $conf->optionExists('server') and $conf->getOption('server') ne ''; $conf->setOption('port',2001) unless $conf->optionExists('port') and $conf->getOption('port') ne ''; $conf->setOption('daemon','0') unless $conf->optionExists('daemon') and $conf->getOption('daemon') == 0; $client->callback( \&loop ); $SIG{'INT'} = $SIG{'TERM'} = sub { $client->shutdown(); }; $client->MainLoop(); sub loop { for (my $i=0; $i<$wait; $i++) { print $wait - $i . " seconds to go +!\r"; sleep 1; } my $broadcast = Net::Peep::BC->new('egg-timer',$conf); $broadcast->send('egg-timer', type=>0, sound=>$sound, location=>12 +8, priority=>0, volume=>255); print "\n\nDing!\n\n"; } # end sub loop __END__

In reply to A Super-Deluxe Egg Timer (TM) by Starky

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.