From 1595cac9f41fea26c6a830ed975af8e2510333ee Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Wed, 26 Jul 2023 14:20:16 -0400 Subject: [PATCH] [mail] Add a notmuch post hook for dunst --- bin/.bin/notify-on-new-mail.py | 18 ++++++++++++++++++ mail/.config/notmuch/default/hooks/post-new | 2 ++ 2 files changed, 20 insertions(+) create mode 100755 bin/.bin/notify-on-new-mail.py create mode 100755 mail/.config/notmuch/default/hooks/post-new diff --git a/bin/.bin/notify-on-new-mail.py b/bin/.bin/notify-on-new-mail.py new file mode 100755 index 0000000..f294d50 --- /dev/null +++ b/bin/.bin/notify-on-new-mail.py @@ -0,0 +1,18 @@ +import json +import subprocess + +new_mail_list = json.loads( + subprocess.check_output( + ["notmuch", "show", "--format=json", "tag:inbox"], + ).decode('utf-8') +) + + +output = "Mail's here!\n\n" +for message in new_mail_list: + msg = message[0][0] + dt = msg['headers']['Date'] + subj = msg['headers']['Subject'] + output += f"{dt}\n{subj}\n\n" + +subprocess.run(["dunstify", output]) diff --git a/mail/.config/notmuch/default/hooks/post-new b/mail/.config/notmuch/default/hooks/post-new new file mode 100755 index 0000000..dc6e206 --- /dev/null +++ b/mail/.config/notmuch/default/hooks/post-new @@ -0,0 +1,2 @@ +#!/bin/sh +python ~/.bin/notify-on-new-mail.py