#!/bin/sh # fetch your mail at regular intervals and on-demand inbox=~/lib/mail/zoho/INBOX tarosock=~/lib/taro/taro.sock if [ "$1" = "-s" ]; then oldnew=$(\ls -1 ${inbox}/new | wc -l) dots=" " mbsync -a & while pgrep mbsync; do case $dots in "...") dots=" ..";; " ..") dots=" .";; " .") dots=" ";; " ") dots=". ";; ". ") dots=".. ";; ".. ") dots="...";; esac notify-send -c mail 'mail' "[syncing${dots}]" sleep 1 done newnew=$(\ls -1 ${inbox}/new | wc -l) if [ ${newnew} -gt ${oldnew} ]; then notify-send -c mail 'new mail' "[${newnew}]" else notify-send -c mail 'mail' "[sync complete]" fi # if [ -S ${tarosock} ]; then # printf "0" | socat UNIX-CONNECT:${tarosock} - # echo "pushed to socket" # fi else oldnew=0 while true; do mbsync -a newnew=$(\ls -1 ${inbox}/new | wc -l) if [ ${newnew} -gt ${oldnew} ]; then notify-send -c mail 'new mail' "[${newnew}]" # if [ -S ${tarosock} ]; then # printf "0" | socat UNIX-CONNECT:${tarosock} - # echo "pushed to socket" # fi fi oldnew=${newnew} sleep 300 echo "slept 5m" done fi