Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: A generic function/framework/mechanism for regular polling of data?



On 2008-08-08 at 03:33 +0200, Richard Hartmann wrote:
> I was wondering if a function existed that will use a pattern, target
> variables, interval & a data source for polling & parsing information
> regularly.
> 
> For example, this function could be told to poll ACPI power status
> every X seconds and put the result into $foo. The same function
> could also keep track of unread mail, the temperature of CPU, HDD,
> etc and pretty much antything else you can get from a file or
> program and put all of those values into variables.
> 
> Does any function like this exist?

Define periodic() and set $PERIOD; every $PERIOD seconds, periodic()
will be called, just before a prompt.  If you don't cause a prompt to be
shown, the function won't be called.

This is done just after precmd() and just before the $WATCH and
$MAILCHECK checks.

There's ALSO a separate list of commands, called after the mailchecks,
maintained by the zsh/sched loadable module.  Those are single-fire
commands, rather than repeating events.

For unread mail, look at $MAILCHECK, $mailpath and the mail_warning
option.  That assumes mbox mail though.

-Phil

Attachment: pgp24qO26xtGd.pgp
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author