summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorAustin Lowery <a.lowery@cpanel.net>2018-04-11 17:40:44 -0500
committerAustin Lowery <a.lowery@cpanel.net>2018-04-11 17:40:44 -0500
commit658a66aa425c14686a96759517f3a691e3cfefbc (patch)
treeb1e434a5b497b183361ae06eedcb4c0182e56736 /etc
parent346e838672e86076aa5ef6fb4a79c7bc76797817 (diff)
Add mac style notifications to mailsync script
Diffstat (limited to 'etc')
-rwxr-xr-xetc/mailsync.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/etc/mailsync.sh b/etc/mailsync.sh
index 3c9bda9..205a1c8 100755
--- a/etc/mailsync.sh
+++ b/etc/mailsync.sh
@@ -26,3 +26,21 @@ new=$(find ~/.mail -wholename '*/new/*' | grep -vi "spam\|trash\|junk" | wc -l)
if [ "$new" -gt "$ori" ]; then
mpv --quiet ~/.config/mutt/etc/notify.opus
fi
+
+for account in $(ls ~/.mail)
+do
+ for mailbox in $(ls ~/.mail/$account/)
+ do
+ #List unread messages newer than last mailsync and count them
+ newcount=$(find ~/.mail/$account/$mailbox/new/ -type f -newer ~/.config/mutt/etc/mailsynclastrun 2> /dev/null | wc -l)
+ #Pop a Mac style notification with the count for that mailbox
+ if [ "$(uname)" == "Darwin" -a "$newcount" -gt "0" ]
+ then
+ osascript -e "display notification \"$newcount in $mailbox\" with title \"Youve got Mail\" subtitle \"Account: $account\""
+ sleep 2
+ fi
+ done
+done
+
+#Create a touch file that indicates the time of the last run of mailsync
+touch ~/.config/mutt/etc/mailsynclastrun