(That's not necessarily a bad thing).
]]>#!/bin/sh
while true; do
notify-send "New Mail" "$(inotifywait -e create -e moved_to ~/.mail/*/INBOX/new 2> /dev/null | cut -f 1 -d " " | cut -d "/" -f 5)"
done
Just need to change the inotifywait path to wherever you keep your mail folder and run it in the background.
]]>I use the following script for watching my maildirs and sending off a notify-send, but it depends on my offlineimap. I'm afraid I don't know whether I wrote the code or someone else did. Possibly it's a mix.
It could probably easily be used with mbox as Python Mailbox supports mbox by default:
#!/usr/bin/env python2
# -*- coding: utf-8; mode: python -*-
import pyinotify
import subprocess
import re
from os.path import expanduser
from mailbox import MaildirMessage
from email.header import decode_header
# Getting the path of all the boxes
fd = open(expanduser("~/.offlineimaprc"), 'r')
f = fd.read()
maildirs = re.findall(r'localfolders = (.+)', f)
fd.close()
icon = expanduser("~/bin/lib/mail.png")
dec_header = lambda h : ' '.join(unicode(s, e if bool(e) else 'ascii') for s, e in decode_header(h))
def newMail(event):
print('event happened!')
f = open(event.pathname, 'r')
print('Examine %s') % event.pathname
Mail = MaildirMessage(message=f)
From = dec_header(Mail['From'])
From = From.split('<')[0]
Subject = "'" + dec_header(Mail['Subject']) + "'"
annoying_spaces = re.compile(r'[\t\n\r\f\v]')
Subject = annoying_spaces.sub('', Subject)
f.close()
s1 = 'New mail from %s' % From
print('Notifying ...')
subprocess.Popen(['notify-send', '-i', icon, s1, Subject])
# Instanciate a new WatchManager (will be used to store watches).
wm = pyinotify.WatchManager()
# Associate this WatchManager with a Notifier (will be used to report and
# process events).
notifier = pyinotify.Notifier(wm, newMail)
for dir in maildirs:
wm.add_watch(expanduser(dir+"/inbox/new/"), pyinotify.IN_CREATE | pyinotify.IN_MOVED_TO)
print('watching %s' %dir)
notifier.loop()
I realize, from both answers, that this is my poor phrasing of my question, but you've both also sort of answered it. My proper question should have been, I use xbuffy or gbuffy to watch multiple mailboxes with mutt. Neither one is maintained any longer, though Debian and BSD developers maintain a working version. Does anyone know of another binary program that does the same thing? If not, why don't people use this anymore?
The answer to the second part is shown by both your answers. It's, Because, aside from me, <sigh> most folks using mutt with multiple mailboxes are pretty knowledgeable and like to tinker with various scripts to allow them to do this. As for you (meaning me---this is someone answering my actual question), as Debian continues to maintain xbuffy, and using alien to make it an rpm still works, you're probably alright for awhile.
I'm not going to mark the thread solved, however, as I do want to hear what other people are doing--even if it's beyond me (or beyond the effort I'm willing to expend), it's really interesting to me, and stuff I will probably play with if I ever get some spare time.
I'm going to look into this stuff--for example, I'd never heard of notify-send till just now.
Once again, I'm going to thank the folks who are taking the time to answer this. Sigh, I guess I am more behind the times than I though.
]]>I use getmail to download my mail, pass it through procmail, and in procmail I call notify-send (as well as filter, etc.).
You can use many things to display a notify-send, but currently I use dunst (see contributions forum).
The reason, IIRC, I wound up choosing mbox was because it was easier, at the time, to get an idea of how much mail I had--after that, it's just become habit. (Haven't used maildir in awhile, but at the time, at least, it would show all directories as being 4k, regardless of what was in them.)
I definitely don't keep enough mail around to require an indexing program--just using the simple mutt tools has always been adequate for my relatively simple needs. (They look interesting though)
]]>There was some research into the performance benefits of maildirs over mbox; mutt seems equally happy with either. If you have a large amount of mail, I'd also recommend mairix or notmuch for indexing: the difference is pretty phenomenal.
]]>(I should also add that I see Arch has gnubiff which is supposed to handle multiple mailboxes, but playing with it, I didn't like it very much). (Ah, a quick google gives me an idea of what you mean by urgency hint.)
Lastly, I'll say (and this goes for any who respond) that whether or not it works for me, thank you for taking the time to answer.
eml(){
maildirs="$HOME/Mail/*/INBOX/new/"
ml="$(find $maildirs -type f | wc -l)"
if [ $ml == 0 ]; then
echo "0"
else
echo -en "\x03$ml\x01"
fi
}
Combined with an urgency hint, it works a treat...
]]>Again MOST sincere thanks to all who have answered.
For years, I've been using gbuffy. At work, we're primarily RH based, and so far, I've managed to get it working with each new version of Fedora. I believe Ubuntu still has a version of xbuffy. (Arch has an unmaintained xbuffy in AUR--I created it in 2006, but abandoned it afterwards. I remember when they pruning AUR, and I think I emailed someone to tell them it was abandoned.)
At any rate, I know that many people here use mutt, and I assume that some work in a similar manner to me, that is, working in X, not having mutt open all the time, but wanting to see if they've gotten any mail. I've been googling around, found some dock apps, most of which seem to be out of date. So, what I'm looking for is a multiple mailbox watcher, similar to gbuffy. Though the FreeBSD port is still available, gbuffy's creator abandoned it years ago, xbuffy is also abandoned. There was also an ebuffy, but that one also didn't build for me.
What do other mutt users use to watch multiple mailboxes in X. (Watching a single mailbox is easy with the still present xbiff)
Thanks for any answers. I've gotten lazier and busier as I age, so simpler solutions are better. I figure people have to be using something, but my googling is getting me nowhere. (Using terms like mailwatch mutt multiple mailbox watcher, and the like.)
]]>