Friday, April 3, 2015

Simple Mail Notification

I synchronize mailboxes with mbsync and read email in Mutt (more specifically my patched version). By default Mutt will check for new email to be found in configured mailboxes, echo simple notification in its window and if configured so ring a bell, which will in turn highlight such urgent workspace in status bar (echoed by window manager — XMonad — and read on STDIN by Xmobar).

Because I get a lot of emails (from mailing lists, VCS commits, etc.) I categorize them into separate folders / mailboxes but really want to be directly notified only for emails found in INBOX. All other emails are processed by batch-like approach something like twice a day. So not to miss something important, I want to get alarmed on INBOX and possibly other specific mailboxes.

I've came up with a simple, rather generic solution utilizing inotify. It continuously monitors configured Maildir directories for changes, and produces line-oriented formatted output (number of new emails, followed by delta from a last wakeup). It also echoes some colors understood by Xmobar, which is also a place from which it gets started by CommandReader plugin.