[mail] Add a notmuch post hook for dunst

This commit is contained in:
2023-07-26 14:20:16 -04:00
parent b7925b2299
commit 1595cac9f4
2 changed files with 20 additions and 0 deletions

18
bin/.bin/notify-on-new-mail.py Executable file
View File

@ -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])

View File

@ -0,0 +1,2 @@
#!/bin/sh
python ~/.bin/notify-on-new-mail.py