dgy
/
hexagons
Archived
1
0
Fork 0
This repository has been archived on 2021-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
hexagons/bin/correo

30 lines
982 B
Plaintext
Raw Normal View History

2019-04-25 03:39:38 +00:00
#!/usr/bin/env sh
# Sync mail and give notification if there is new mail.
2019-04-22 16:17:15 +00:00
pgrep -u "$USER" >/dev/null || exit
2019-04-25 03:39:38 +00:00
ping -q -c 1 1.1.1.1 > /dev/null || exit
2019-04-22 16:17:15 +00:00
2019-04-25 03:39:38 +00:00
export DISPLAY=:0.0
2019-04-22 16:17:15 +00:00
notify() { notify-send -i ~/Pictures/.icn/correo.png "You've got mail" "$2 new message(s) in \`$1\` " ;}
2019-04-22 16:17:15 +00:00
2019-04-25 03:39:38 +00:00
# Run mbsync. You can feed this script different settings.
if [ $# -eq 0 ]; then
mbsync -a
else
mbsync "$@"
fi
2019-04-22 16:17:15 +00:00
2019-04-25 03:39:38 +00:00
# Check all accounts/mailboxes for new mail. Notify if there is new content.
for account in "$HOME/.local/share/mail/"*
do
acc="$(echo "$account" | sed "s/.*\///")"
newcount=$(find "$HOME/.local/share/mail/$acc/INBOX/new/" "$HOME/.local/share/mail/$acc/Inbox/new/" "$HOME/.local/share/mail/$acc/inbox/new/" -type f -newer "$HOME/.config/mutt/.mailsynclastrun" 2> /dev/null | wc -l)
[ "$newcount" -gt "0" ] && notify "$acc" "$newcount" &
done
notmuch new 2>/dev/null
#Create a touch file that indicates the time of the last run of mailsync
touch "$HOME/.config/mutt/.mailsynclastrun"