Subject: [sup-talk] new in svn: hook system and polling hooks

From: [email-masked] (William Morgan)
Date: Sat, 18 Aug 2007 18:03:57 -0700

I've added a system for hooking user-created code into Sup. (Finally!)

Sup hooks take the form of Ruby scripts, placed in ~/.sup/hooks. Each
hook corresponds to a file in that directory. To see documentation on
the available hooks, just run "sup -l".

Hooks are passed information in the form of local "variables" (really
method calls, so don't try assigning to them). There are two
Sup-specific functions they can call, "say" and "log". "say" will write
a temporary message to the bottom portion of the screen, which is erased
when the hook stops executing. "log" will write a message to the sup
log.

There are only two hooks right now, before-poll and after-poll.
Before-poll should satisfy the desire of fetchmail users and after-poll
should satisfy the desire of all xbiff users.

Future work:
Allow sharing of information between successive invocations via instance
variables; and add lots of hooks (some kind of mime handler is probably
my immediate goal.)

-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (William Morgan)
Date: Sun, 19 Aug 2007 18:30:26 -0700

Excerpts from William Morgan's message of Sat Aug 18 18:03:57 -0700 2007:
> variables

Ok, this is in. Here's how I'm handling fetchmail invocation. In
hooks/before-poll.rb:

  if (@last_fetchmail_time || Time.at(0)) < Time.now - 60
    say "Running fetchmail..."
    system "fetchmail >& /dev/null"
  end
  @last_fetchmail_time = Time.now