On Wed, Mar 27, 2002 at 11:27:20AM -0800 I heard the voice of
Post by Clint OlsenI was looking up how to write a nice test (in sh) for new mail delivery to
my spoolfile so that xbiff would work correctly. My guess is that someone
has done this already. Anyone care to share? There aren't any simple
tests(1) for directory modification.
Obvious hacks possible for differing Maildir locations. Note that it
doesn't QUITE duplicate the mbox behavior exactly (it tries to, but for
reasons I never cared enough about to really dig into, it doesn't), but
it's nearly the same. It doesn't very well handle monitoring more than
one Maildir/ (or being invoked by more than one process) per user; you'd
need to hack it further for that. I just use xbiff for my inbox, and use
xbuffy (which has native Maildir support) for the rest.
If you didn't care to try and figure out why the "non-new but unread"
case isn't working, you could theoretically make it more efficient
(especially when you get 4 digits or so of new/ messages) by using a
/bin/ls -f instead of the -lT.
<ramble>
#!/bin/sh
# Quick check of Maildir/ for new mail
# Author: Matthew Fuller
# <***@over-yonder.net> <http://www.over-yonder.net/~fullermd>
CURFILE="$HOME/.maildircheck/cur"
PREVFILE="$HOME/.maildircheck/prev"
/bin/mkdir -p $HOME/.maildircheck
/bin/ls -lT $HOME/Maildir/new/ > $CURFILE
if [ "`wc -l $CURFILE | awk '{print $1}'`" != "0" ]; then
if [ -f $PREVFILE ]; then
if(!(cmp -s $CURFILE $PREVFILE)); then
mv $CURFILE $PREVFILE
# New and unread messages
exit 0
fi
# Non-new but unread
mv $CURFILE $PREVFILE
exit 1
fi
mv $CURFILE $PREVFILE
exit 0
fi
mv $CURFILE $PREVFILE
# No messages
exit 2
--
Matthew Fuller (MF4839) | ***@over-yonder.net
Unix Systems Administrator | ***@futuresouth.com
Specializing in FreeBSD | http://www.over-yonder.net/
"The only reason I'm burning my candle at both ends, is because I
haven't figured out how to light the middle yet"
To Unsubscribe: send mail to ***@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message