Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brunohcastro/93d2b8f8b779ed06befe1f2eb723fb77 to your computer and use it in GitHub Desktop.
Save brunohcastro/93d2b8f8b779ed06befe1f2eb723fb77 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