2021-11-27 05:50:27 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-01-15 05:33:32 +00:00
|
|
|
# fetch your mail at regular intervals
|
|
|
|
# Derek Stevens <nilix@nilfm.cc>
|
|
|
|
# MIT License
|
|
|
|
|
2022-03-26 15:10:26 +00:00
|
|
|
inbox=~/lib/mail/zoho/INBOX
|
2023-03-28 05:19:23 +00:00
|
|
|
tarosock=~/src/taro/taro.sock
|
2022-03-26 15:10:26 +00:00
|
|
|
|
|
|
|
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}]"
|
2023-03-28 05:19:23 +00:00
|
|
|
if [ -S ${tarosock} ]; then
|
|
|
|
printf "0" | socat UNIX-CONNECT:${tarosock} -
|
|
|
|
fi
|
2022-03-26 15:10:26 +00:00
|
|
|
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}]"
|
2023-03-28 05:19:23 +00:00
|
|
|
if [ -S ${tarosock} ]; then
|
|
|
|
printf "0" | socat UNIX-CONNECT:${tarosock} -
|
|
|
|
fi
|
2022-03-26 15:10:26 +00:00
|
|
|
fi
|
|
|
|
oldnew=${newnew}
|
|
|
|
sleep 5m
|
|
|
|
done
|
|
|
|
fi
|