aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-05-13 15:12:31 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-05-13 15:12:31 -0500
commit5a029f2648895d90f758efe8c0ab1ff338b882fc (patch)
tree669104c33ca65a7986cd2f45fba6edbfcb55772f
parent18f1079aad39bc4ad49bf9a4f7efe76e97fbdb9a (diff)
fix(mail): simplify notify script
-rwxr-xr-xmbsync/.local/bin/maildir-notify27
1 files changed, 9 insertions, 18 deletions
diff --git a/mbsync/.local/bin/maildir-notify b/mbsync/.local/bin/maildir-notify
index 61fc434..f598f69 100755
--- a/mbsync/.local/bin/maildir-notify
+++ b/mbsync/.local/bin/maildir-notify
@@ -1,28 +1,19 @@
#!/bin/sh
for maildir; do
- echo "Monitoring $maildir"
+ printf 'monitoring: %s\n' "$maildir"
set -- "$@" "${maildir}/new"
shift
done
inotifywait --monitor --event create --event moved_to "$@" |
while read -r dir _action file; do
- maildir="$(dirname "$dir")"
- category="$(dirname "$maildir" | xargs basename)"
- from="$(grep -m1 -oP '(?<=^From: ).*' "${dir}${file}")"
- subject="$(grep -m1 -oP '(?<=^Subject: ).*' "${dir}${file}")"
-
- if [ ! -e "$maildir/new/$file" ]; then
- if [ -e "$maildir/cur/$file" ]; then
- from="$(grep -m1 -oP '(?<=^From: ).*' "$maildir/cur/$file")"
- subject="$(grep -m1 -oP '(?<=^Subject: ).*' "$maildir/cur/$file")"
- else
- echo "Failed to read message. File: $file" 1>&2
- continue
- fi
- fi
-
- echo "Category: $category, From: $from, Subject: $subject"
- notify-send -a "Mail" -c "$category" "From: $from" "$subject"
+ grep '^\(Subject\|From\|To\): .*$' <"${dir}${file}" |
+ sed -e 's/</\&lt\;/g' -e 's/>/\&gt\;/g' |
+ notify-send \
+ -a 'maildir-notify' \
+ -c 'email.arrived' \
+ -i 'mail-unread-symbolic' \
+ 'You have new mail' \
+ "$(cat -)"
done