You are not logged in.
Pages: 1
I've run into two issues with Mutt and OfflineIMAP. I'm wondering how those zillions of Mutt/OfflineIMAP users are keeping up with their new emails.
1) How do I execute a command (like xmessage or aplay) when I receive an email? Do I need one of those (seemingly) complicated message-hooks?
2) Is Mutt's mailbox view the only way to get an overview of all mailboxes and their new emails? How do I make it refresh automatically (without pressing "yy")?
Offline
1. You can set mutt to beep on new message - this translates to an urgency hint that you can have most window managers pick up: or leave your speaker on.
2. You can write a simple script to display the number of new mails in your boxes. There is also a mutt-sidebar in AUR if that is what you are after. If by refresh, you mean check for new mail, you can runs a script from cron - see brisbin33's primer
Offline
You could also use the inotify-tools package and listen for filesystem changes in your mail spool/inbox.
Offline
Thanks for your answers! I just found this nice script: http://www.toxahost.ru/projects.html
That's all I need for notifications.
Concerning the refreshing of the mailbox view (the one that opens with "y"). I've set Mutt to check my OfflineIMAP mailboxes frequently but no "N" flag will ever appear. Reopening the view with "yy" instantly shows the correct "N" flags. (Therefore it's not OfflineIMAP that is frozen.)
Offline
The script I linked simply counts files in the mailbox folder. If you mark a message as read and receive a message between two checks, you won't get notified. I came up with the following unpolished script:
#!/bin/sh
boxes=("$HOME/mail/a" "$HOME/mail/b")
names=("Mailbox A:" "Mailbox B:")
text=""
new_mail=false
first_check=true
while true; do
for i in {0..1}; do
if $first_check; then
new=`find ${boxes[i]}/inbox/new/ -type f -print | wc -l`
else
new=`find ${boxes[i]}/inbox/new/ -type f -cmin -1 -print | wc -l`
fi
text="${text}${names[i]}\t$new\n"
if [ $new -gt 0 ];then
new_mail=true
fi
done
if $new_mail; then
aplay -q $HOME/notify.wav &
echo -e "$text" | zenity --text-info --width 180 --height 170
fi
text=""
new_mail=false
first_check=false
sleep 60
done
One issue is that a mail could arrive between "sleep 60" and "find ... -cmin -1". I guess that happens not all that often. Also if you receive 10 new emails while being away from your computer, you probably end up with ten dialogs to close...
There is also "mailcheck" in AUR: https://aur.archlinux.org/packages.php? … 7&detail=0
"inotify" could also be worth a look: http://en.wikipedia.org/wiki/Inotify (or see pyinotify: https://github.com/seb-m/pyinotify)
Last edited by Markus00000 (2011-04-13 23:13:00)
Offline
A slightly less annoying and slightly more polished notification script:
#!/bin/sh
## Time between checks
interval=60
## Mailboxes to check
boxes=("$HOME/mail/gmail1" "$HOME/mail/gmail2")
## Number of mailboxes
box_count=${#boxes[@]}
new_mail=false
## Notify upon new mail
notify () {
if [[ $new_mail == true ]]; then
echo -e "You have new mail!" | zenity --text-info --width 170 &
pid=$!
aplay -q $HOME/alarm.wav &
new_mail=false
fi
}
## Find the highest message ID for each mailbox
## This allows marking old messages new without notification
last_mail () {
for (( i = 0; i < $box_count; i++ )); do
last_cur=`ls -lr ${boxes[i]}/inbox/cur | sed -n 2p | awk -F , '{ print $2 }' | cut -c 3-`
last_new=`ls -lr ${boxes[i]}/inbox/new | sed -n 2p | awk -F , '{ print $2 }' | cut -c 3-`
if [[ $last_new == "" ]]; then
last_new=0
fi
if [[ $last_cur -gt $last_new ]]; then
last[i]=$last_cur
else
last[i]=$last_new
fi
done
}
last_mail
## First check: Notify if any new mail is found
for (( i = 0; i < $box_count; i++ )); do
new=`find ${boxes[i]}/inbox/new/ -type f -print | wc -l`
if [[ $new -gt 0 ]]; then
new_mail=true
fi
done
notify
## Check 2..n: Notify if a new mail (higher ID) is found and there are no previous notification windows
while true; do
sleep $interval
## Check if previous notification window still open
kill -0 $pid
running=$?
## 1: closed, 0: open
if [[ $running = "1" ]]; then
last_previous=("${last[@]}")
last_mail
for (( i = 0; i < $box_count; i++ )); do
if [[ ${last[i]} -gt ${last_previous[i]} ]]; then
new_mail=true
fi
done
notify
else
last_mail
fi
done
Offline
Nicolas: I'm going to split the last three posts of yours out into a separate (new) thread in Community Contributions as this is really stand-alone now.
Offline
Pages: 1