Return-Path: <david@santinoli.com>
Delivered-To: abz@oasis.frogfoot.net
Received: (qmail 24298 invoked from network); 11 Apr 2001 23:34:55 -0000
Received: from unknown (HELO swim.frogfoot.net) (66.8.28.1)
  by 66.8.28.51 with SMTP; 11 Apr 2001 23:34:55 -0000
Received: (qmail 9837 invoked by uid 1007); 11 Apr 2001 23:39:14 -0000
Delivered-To: abz@swim.frogfoot.net
Received: (qmail 9834 invoked by uid 888); 11 Apr 2001 23:39:14 -0000
Delivered-To: blio-net-abz@blio.net
Received: (qmail 9832 invoked from network); 11 Apr 2001 23:39:12 -0000
Received: from ems.flashnet.it (HELO relay.flashnet.it) (root@194.247.160.44)
  by 66.8.28.1 with SMTP; 11 Apr 2001 23:39:12 -0000
Received: from aidi.santinoli.com (adsl027.18.cyb.it [195.191.18.27])
	by relay.flashnet.it (EMS-RELAY/8.10.0) with ESMTP id f3BNYnT02506
	for <abz@blio.net>; Thu, 12 Apr 2001 01:34:50 +0200
Received: by aidi.santinoli.com (Postfix, from userid 502)
	id B19A95651; Thu, 12 Apr 2001 01:34:33 +0200 (CEST)
Date: Thu, 12 Apr 2001 01:34:33 +0200
From: David Santinoli <david@santinoli.com>
To: abz@blio.net
Subject: [ixbiff] "new mail" patch
Message-ID: <20010412013433.A23729@aidi.santinoli.com>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="mP3DRpeJDSE+ciuQ"
Content-Disposition: inline
User-Agent: Mutt/1.3.17i
Content-Length: 1686


--mP3DRpeJDSE+ciuQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline


Hi,
  I'm a happy user of ixbiff. It works great - don't have to wake up my monitor
from energy saving mode just to see if there's new mail :-) Still, I found
a bit annoying to have the LED keep blinking on old mail. So I produced this
little hack which blinks only when actual new mail is found in a mailbox (just
updated the code for the mbox case, not maildir).
It works by comparing mbox file's access time vs modification time.
Don't know if other people might find it useful; maybe adding a config var to
enable/disable this kind of test could be a suitable strategy.

Blue skies,
 David

--mP3DRpeJDSE+ciuQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline; filename=newmail_patch

diff -urN ixbiff-0.01a.virgin/src/ixbiff.c ixbiff-0.01a/src/ixbiff.c
--- ixbiff-0.01a.virgin/src/ixbiff.c	Wed Nov 22 14:47:00 2000
+++ ixbiff-0.01a/src/ixbiff.c	Thu Apr 12 00:55:54 2001
@@ -84,11 +84,12 @@
 inline void setled (int n) { led[n] = TRUE; }
 inline void clrled (int n) { led[n] = FALSE; }
 
-size_t fsize (const char *filename)
+bool newmail (const char *filename)
 {
    struct stat tmp;
    if (stat (filename,&tmp) < 0) syslog (LOG_ERR,"stat(%s): %m",filename);
-   return (tmp.st_size);
+   if (tmp.st_size > 0 && tmp.st_mtime > tmp.st_atime) return TRUE;
+   return FALSE;
 }
 
 bool isdir (const char *name)
@@ -185,7 +186,7 @@
 		  {
 			 for (i = 0; i < 3; i++) if (mbox[i] != NULL)
 			   {
-				  if (fsize (mbox[i])) setled (i); else clrled (i);
+				  if (newmail (mbox[i])) setled (i); else clrled (i);
 			   }
 		  }
 		flashleds ();

--mP3DRpeJDSE+ciuQ--
