Explorar o código

[mail] Add a notmuch post hook for dunst

Colin Powell %!s(int64=2) %!d(string=hai) anos
pai
achega
1595cac9f4
Modificáronse 2 ficheiros con 20 adicións e 0 borrados
  1. 18 0
      bin/.bin/notify-on-new-mail.py
  2. 2 0
      mail/.config/notmuch/default/hooks/post-new

+ 18 - 0
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])

+ 2 - 0
mail/.config/notmuch/default/hooks/post-new

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