From 3049b27fa5c7874db802b8fbdf2e016abe87fd9e Mon Sep 17 00:00:00 2001
From: Luke Smith <luke@lukesmith.xyz>
Date: Mon, 5 Mar 2018 23:38:22 -0700
Subject: notify system added

---
 etc/mailsync.sh |  23 +++++++++++++++++++++++
 etc/notify.opus | Bin 0 -> 28900 bytes
 2 files changed, 23 insertions(+)
 create mode 100755 etc/mailsync.sh
 create mode 100644 etc/notify.opus

(limited to 'etc')

diff --git a/etc/mailsync.sh b/etc/mailsync.sh
new file mode 100755
index 0000000..14b165e
--- /dev/null
+++ b/etc/mailsync.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+# This script will run offlineimap and check
+# for new email if there is an internet connection.
+#
+# If it detects new mail, it uses mpv to play a
+# notification sound: notify.opus
+#
+# I have this run as a cronjob every 5 minutes.
+
+# Check for internet connection. Exit script if none.
+ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` >/dev/null || exit
+
+# Get current number of new mail, then begin sync.
+ori=$(find ~/.mail -wholename '*/new/*' | grep /new/ | grep -vi "spam\|trash\|junk" | wc -l)
+offlineimap -o
+
+# Output new new mail count.
+new=$(find ~/.mail -wholename '*/new/*' | grep /new/ | grep -vi "spam\|trash\|junk" | wc -l)
+
+# If new mail has grown, play a notification.
+if [ "$new" -gt "$ori" ]; then
+	mpv --quiet ~/.config/mutt/etc/notify.opus
+fi
diff --git a/etc/notify.opus b/etc/notify.opus
new file mode 100644
index 0000000..a76ce32
Binary files /dev/null and b/etc/notify.opus differ
-- 
cgit v1.2.3