zenUtils/sirius.sh
2022-03-26 09:10:26 -06:00

40 lines
755 B
Bash
Executable file

#!/bin/sh
# fetch your mail at regular intervals
# Derek Stevens <nilix@nilfm.cc>
# MIT License
inbox=~/lib/mail/zoho/INBOX
if [ "$1" = "-s" ]; then
oldnew=$(\ls -1 ${inbox}/new | wc -l)
msg="syncing."
mbsync -a &
while pgrep mbsync; do
notify-send -c mail 'mail' "[${msg}]"
sleep 1
msg=${msg}.
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
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}]"
fi
oldnew=${newnew}
sleep 5m
done
fi