I use mutt and offlineimap to manage email on my Arch Linux machines. I like the simplicity and the power that this approach offers; that’s power in the sense of extensibility and customization, by the way…
Using dwm as my window manager, I had relied on conky and dzen2 to pipe system information into my status bar. Unfortunately, conky only supports one mail spool so if, like me, you use offlineimap to synchronize multiple mailboxes, conky would only show new mail in your primary box. I had asked in #conky about multiple mail spools, but it doesn’t seem to be supported.
When I recently started using WMFS I decided to move to a bash script for my status information. So I approached the problem afresh and decided to write a script to poll the new mail directories and update my status bar when mail arrived.
Offlineimap creates a directory structure like so:
Mail/ ------- | | | Mail_Account_1 | | | | -- INBOX | | | -- cur | | | -- new | | | -- temp | | | | -- INBOX.Drafts | | | -- cur
As I was only interested in checking the INBOX/new directory of each account, I had imagined that it would be necessary to set up some elaborate array to effectively check each of the requisite sub-directories…
1 2 3 4 5 6
The glob (
*) takes care of the different mail account names, and has
the added bonus of being portable, and find returns any files (
wc counting the number of lines (the