Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
offlineimap-notify.sh
#!/usr/bin/bash
#
# Script to notify user for new mails.
# Crontab ex:
# */3 * * * * ~/bin/offlineimap-notify.sh
#
#run OfflineIMAP once, with quiet interface
offlineimap -o -q -u quiet
#count new mail for every maildir
maildirnew="$HOME/Maildir/*/*/new/"
new="$(find $maildirnew -type f | wc -l)"
#count old mail for every maildir
maildirold="$HOME/Maildir/*/*/cur/"
old="$(find $maildirold -type f | wc -l)"
if [ $new -gt 0 ]
then
export DISPLAY=:0; export XAUTHORITY=~/.Xauthority;
notify-send -a "OfflineIMAP" "New mail!\nNew: $new Old: $old"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.