Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Mar 2002 09:55:20 -0600
From:      "Matthew D. Fuller" <fullermd@over-yonder.net>
To:        Clint Olsen <clint@0lsen.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Xbiff that works with maildir folders
Message-ID:  <20020328095520.J15139@over-yonder.net>
In-Reply-To: <20020327192720.GA94751@0lsen.net>; from clint@0lsen.net on Wed, Mar 27, 2002 at 11:27:20AM -0800
References:  <20020327192720.GA94751@0lsen.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 27, 2002 at 11:27:20AM -0800 I heard the voice of
Clint Olsen, and lo! it spake thus:
> I 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
# <fullermd@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)     |    fullermd@over-yonder.net
Unix Systems Administrator      |    fullermd@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 majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020328095520.J15139>