Skip to content

Instantly share code, notes, and snippets.

@nlamirault
Created September 21, 2014 14:00
Show Gist options
  • Save nlamirault/38cfc46682eaeb28709e to your computer and use it in GitHub Desktop.
Save nlamirault/38cfc46682eaeb28709e to your computer and use it in GitHub Desktop.
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