summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmailsync.sh3
-rwxr-xr-xxbiff-checkcommand-maildir76
2 files changed, 78 insertions, 1 deletions
diff --git a/mailsync.sh b/mailsync.sh
index 2c9f5b5..ce7a8f5 100755
--- a/mailsync.sh
+++ b/mailsync.sh
@@ -1,3 +1,4 @@
#!/bin/sh
-mbsync -a
+mbsync -aq
+notmuch 2>& 1 > /dev/null
diff --git a/xbiff-checkcommand-maildir b/xbiff-checkcommand-maildir
new file mode 100755
index 0000000..824e584
--- /dev/null
+++ b/xbiff-checkcommand-maildir
@@ -0,0 +1,76 @@
+#!/usr/local/bin/bash
+#
+# $Id: xbiff-checkcommand-maildir,v 1.1 2004/06/19 11:50:37 suter Exp $
+# Copyright (C) 2004 Mark Suter <suter@humbug.org.au>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# This will allow you to continue using xbiff(1) after you changed from
+# mbox to maildir for your email. From the manpage:
+#
+# checkCommand (class CheckCommand)
+# Specifies a shell command to be executed to check for new
+# mail rather than examining the size of file. The specified
+# string value is used as the argument to a system(3) call and
+# may therefore contain i/o redirection. An exit status of 0
+# indicates that new mail is waiting, 1 indicates that there has
+# been no change in size, and 2 indicates that the mail has been
+# cleared. By default, no shell command is provided.
+#
+# Here's an example usage from my ~/.Xresources:
+#
+# xbiff*checkCommand: /home/suter/bin/xbiff-checkcommand-maildir /home/suter/mail/In/inbox/
+# xbiff*update: 45
+#
+
+## Our "die" function (think perl)
+die () { echo "$@" 1>&2 ; exit 3 ; }
+
+## Check for our needed binaries
+hash test basename cat find wc touch || die $0: required binaries not present
+
+## We expect one arguemnt, the maildir directory
+maildir="$1"
+test -n "$maildir" || die Usage: $(basename $0) maildir
+test -d $maildir || die $0: Thing \"$maildir\" is not a directory.
+test -d $maildir/new || die $0: Directory \"$maildir\" does not have a new subdir.
+
+## We need to keep state
+count=${TMPDIR:-/tmp}/.xbiff-checkcommand-maildir.count
+state=${TMPDIR:-/tmp}/.xbiff-checkcommand-maildir.state
+
+## Read the stored count (zero on error)
+old=$(cat $count 2>/dev/null)
+test -n "$old" || old=0
+
+## Get current count of emails newer than our state file
+if test -e $state ; then
+ new=$(find $maildir/new/ -type f -newer $state -print | wc -l)
+else
+ new=$(find $maildir/new/ -type f -print | wc -l)
+fi
+
+## Write the count for next time
+echo $new > $count || die $0: error writing state
+
+## Exit correctly (according the man page above)
+test $new -eq 0 -a $old -ne 0 && touch $state && exit 2 # new emails cleared
+test $old -ge $new && exit 1 # no new arrivals since last check
+test $old -lt $new && exit 0 # more new emails than last check
+
+## Catch fallthough
+die $0: should never be reached
+
+