2021-11-27 05:50:27 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2024-09-26 04:15:43 +00:00
|
|
|
# fetch your mail at regular intervals and on-demand
|
2022-01-15 05:33:32 +00:00
|
|
|
|
2022-03-26 15:10:26 +00:00
|
|
|
inbox=~/lib/mail/zoho/INBOX
|
2023-12-10 06:49:21 +00:00
|
|
|
tarosock=~/lib/taro/taro.sock
|
2022-03-26 15:10:26 +00:00
|
|
|
|
|
|
|
if [ "$1" = "-s" ]; then
|
|
|
|
oldnew=$(\ls -1 ${inbox}/new | wc -l)
|
|
|
|
|
2023-12-10 06:49:21 +00:00
|
|
|
dots=" "
|
2022-03-26 15:10:26 +00:00
|
|
|
mbsync -a &
|
|
|
|
|
|
|
|
while pgrep mbsync; do
|
2023-12-10 06:49:21 +00:00
|
|
|
case $dots in
|
|
|
|
"...")
|
|
|
|
dots=" ..";;
|
|
|
|
" ..")
|
|
|
|
dots=" .";;
|
|
|
|
" .")
|
|
|
|
dots=" ";;
|
|
|
|
" ")
|
|
|
|
dots=". ";;
|
|
|
|
". ")
|
|
|
|
dots=".. ";;
|
|
|
|
".. ")
|
|
|
|
dots="...";;
|
|
|
|
esac
|
|
|
|
notify-send -c mail 'mail' "[syncing${dots}]"
|
2022-03-26 15:10:26 +00:00
|
|
|
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
|
|
|
|
|
2024-09-26 04:15:43 +00:00
|
|
|
# if [ -S ${tarosock} ]; then
|
|
|
|
# printf "0" | socat UNIX-CONNECT:${tarosock} -
|
|
|
|
# echo "pushed to socket"
|
|
|
|
# fi
|
|
|
|
|
2022-03-26 15:10:26 +00:00
|
|
|
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}]"
|
2024-09-26 04:15:43 +00:00
|
|
|
# if [ -S ${tarosock} ]; then
|
|
|
|
# printf "0" | socat UNIX-CONNECT:${tarosock} -
|
|
|
|
# echo "pushed to socket"
|
|
|
|
# fi
|
2022-03-26 15:10:26 +00:00
|
|
|
fi
|
|
|
|
oldnew=${newnew}
|
2024-09-26 04:15:43 +00:00
|
|
|
sleep 300
|
2023-12-10 06:49:21 +00:00
|
|
|
echo "slept 5m"
|
2022-03-26 15:10:26 +00:00
|
|
|
done
|
|
|
|
fi
|