1
How can I determine if there is unread mail on my OSX box?
Mail is fetched from a variety of places with fetchmail, and delivered to my local user in /var/mail/user. I am searching for a way to find out if there is unread mail, or if I have read the mail (using alpine). I prefer a solution that uses unix tools, but am open to AppleScript or any other solution for the unread count part, but it must work with unix mail readers (/var/mail/user).
I'd like to have a command line tool that says if there is unread mail in the inbox, so that I can run it with a cron job, and use the keyboard_leds tool to set subtle notifiers. I prefer this to MacBiff, growlnotify, etc.
I thought I figured out one possible solution:
mail -H | grep -c '^.[NU]'
seems to sometimes return the number of unread messages. But if I read a message in alpine, it doesn't update until I quit alpine.
Another approach might be to use my mail client (alpine) directly. I have a clean .pinerc which has no colors, etc trying to make the display as simple as possible, and then run this command:
alpine -o -x .pinerc.clean -I i,q >& foo
Which runs alpine, goes to the Inbox, and then quits (leaving the inbox in read-only mode so as to not disrupt my main alpine process which is viewing the inbox). The screen dump of the inbox is stored in the file "foo".
However, foo the last screen (quitting message, not inbox) and is a binary file in this case, and I cannot figure out how to parse it for the "N" in the column that designates unread mail, even if it were there...
1Is this a question or a blog? And are you going to award the bounty to yourself, yourself or yourself? Please group all your trials and conclusions into your post, delete all your answers and define clearly your question. At the moment it's quiet hard to understand what is exactly the point here. – harrymc – 2010-09-08T20:56:37.100
This is a question. The FAQ states, "...Document your own continued efforts to answer your question.", which is what I was doing. – None – 2010-09-08T22:37:30.170
I know it says that and it's not a bad thing, it merely becomes hard to understand your progress when it's divided over 3 answers and the question itself! =) – BloodPhilia – 2010-09-08T23:02:48.293
It's much clearer when you restrict yourself to your post and let others supply the answers, even if you have found the answer yourself. – harrymc – 2010-09-09T10:36:43.667