diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2024-05-13 15:12:31 -0500 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2024-05-13 15:12:31 -0500 |
commit | 5a029f2648895d90f758efe8c0ab1ff338b882fc (patch) | |
tree | 669104c33ca65a7986cd2f45fba6edbfcb55772f /mbsync/.local/bin/maildir-notify | |
parent | 18f1079aad39bc4ad49bf9a4f7efe76e97fbdb9a (diff) |
fix(mail): simplify notify script
Diffstat (limited to 'mbsync/.local/bin/maildir-notify')
-rwxr-xr-x | mbsync/.local/bin/maildir-notify | 27 |
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/</\<\;/g' -e 's/>/\>\;/g' | + notify-send \ + -a 'maildir-notify' \ + -c 'email.arrived' \ + -i 'mail-unread-symbolic' \ + 'You have new mail' \ + "$(cat -)" done |