-
-
Save brunohcastro/93d2b8f8b779ed06befe1f2eb723fb77 to your computer and use it in GitHub Desktop.
offlineimap-notify.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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