summaryrefslogtreecommitdiffstatshomepage
path: root/mbsync/.local/bin/maildir-notify
diff options
context:
space:
mode:
Diffstat (limited to 'mbsync/.local/bin/maildir-notify')
-rwxr-xr-xmbsync/.local/bin/maildir-notify20
1 files changed, 20 insertions, 0 deletions
diff --git a/mbsync/.local/bin/maildir-notify b/mbsync/.local/bin/maildir-notify
new file mode 100755
index 0000000..61b8d40
--- /dev/null
+++ b/mbsync/.local/bin/maildir-notify
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+if [ $# = 0 ]; then
+ set -- "$MAIL"
+fi
+
+for i; do
+ set -- "$@" "${i}/new"
+ shift
+done
+
+inotifywait --monitor --event create --event moved_to "$@" |
+ while read -r dir _action file; do
+ catagory="$(dirname "$dir" | xargs dirname | xargs basename)"
+ from="$(grep -m1 -oP '(?<=^From: ).*' "${dir}${file}")"
+ subject="$(grep -m1 -oP '(?<=^Subject: ).*' "${dir}${file}")"
+
+ echo "Catagory: $catagory, From: $from, Subject: $subject"
+ notify-send -a "Mail" -c "$catagory" "From: $from" "$subject"
+ done