Parse if there have been new mails synched to the local dir.

Tomasz Żok tomasz.zok at
Tue Jan 29 22:37:20 GMT 2013


you can have something like this in the .offlineimaprc:

[Account NAME]
postsynchook = /path/to/any/

I am using Awesome as a window manager and it has the library named Vicious
that shows the required info from maildir using the following:

    1) To check how many new messages you have:
        find /path/to/MAILDIR/ -type f -wholename '*/new/*' | wc -l

    2) To check how many old but unseen messages you have:
        find /path/to/MAILDIR/ -type f -regex '.*/cur/.*2,[^S]*$' | wc -l

An even better option would be to use inotify which will not use any CPU or
disk IO. It will be simply informed by kernel when new email shows up. I had
once such script, but lost it and did not have motivation to rewrite it yet ;).
But it is possible in a shell script, it is nothing complicated so maybe
someone else from the mailing list came with such solution and would like to

Best regards,
Tomasz Zok

On 01/29/13 at 11:15pm, Profpatsch wrote:
> Hi offlineimap team,
> I’m setting up offlineimap with mutt atm and want to write a small
> script that pipes a “New Mail” to my i3status when there is any.
> I studied oi’s output but I haven’t found any indication that I could
> parse to see if there are new mails.
> The script I’ve come up with so far is doing a
> `find $MAIL -printf %t | md5sum`
> which creates a hash over the last modified times of the whole maildir.
> Then it checks with the hash from the last run and if they differ, the
> statusbar shows “Mail changed” until the next run (which is a cron job
> done every ~5 minutes).
> But it can only see when there are changes to the maildir (and it
> somehow deleted my whole maildir once—lucky me has backups).
> Any ideas?
> ~Profpatsch

More information about the OfflineIMAP-project mailing list