dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit b91e84b469b773704193c08c5511781fcc018f4e
parent 43ee9dd9cc53a3ee3f20f4a2051333fde0f4b56a
Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date:   Wed, 24 Feb 2016 13:42:21 -0800

add notification for new mail

Diffstat:
Mbin/mailcheck.sh | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/bin/mailcheck.sh b/bin/mailcheck.sh @@ -30,6 +30,26 @@ if ps $pid &>/dev/null; then exit 1 fi +# count new mail for every maildir +maildirnew="$HOME/Mail/*/INBOX/new/" +new="$(find $maildirnew -type f | wc -l | sed 's/ //g')" +mailboxes="$(find $maildirnew -type f | sed 's/.*Mail\///' | sed 's/\/INBOX.*//')" +if [ $new -gt 0 ]; then + + UNAMESTR=`uname` + announcement="New mail: $new\nIn $mailboxes" + if [[ "$UNAMESTR" == 'Darwin' ]]; then + osascript -e "display notification \"$announcement\" with title \"offlineimap\"" + + # Linux + elif [[ "$UNAMESTR" == 'Linux' ]]; then + export DISPLAY=:0; export XAUTHORITY=~/.Xauthority + notify-send "$announcement" + fi +fi + + + #/usr/local/bin/offlineimap -o -u quiet & monitor $! # sync INBOXes only