aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/notmuch/.local/bin
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-05-15 20:03:30 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-05-15 20:16:37 -0500
commit5bf571df14cd2ed7cf6ca6ecadc26da53d61af06 (patch)
tree47942cf31b8fb04a35eb7cb6406117f94a5f2b77 /notmuch/.local/bin
parent69e420c803099db126fffd3ca4bac5e396da4e1d (diff)
feat(mail): move all mail stuff inside notmuch hooks
Diffstat (limited to 'notmuch/.local/bin')
-rwxr-xr-xnotmuch/.local/bin/notmuch-notify34
1 files changed, 34 insertions, 0 deletions
diff --git a/notmuch/.local/bin/notmuch-notify b/notmuch/.local/bin/notmuch-notify
new file mode 100755
index 0000000..f808c4d
--- /dev/null
+++ b/notmuch/.local/bin/notmuch-notify
@@ -0,0 +1,34 @@
+#!/bin/python
+
+import notmuch
+import subprocess
+import os
+
+
+def notify(title, message):
+ subprocess.Popen(
+ [
+ "notify-send",
+ "--app-name=notmuch-notify",
+ "--category=email.arrived",
+ "--icon=mail-unread",
+ title,
+ message,
+ ]
+ )
+
+
+for message in (
+ notmuch.Database(
+ path="{}/mail".format(
+ os.getenv("XDG_DATA_HOME", os.path.expanduser("~/.local/share"))
+ ),
+ mode=notmuch.Database.MODE.READ_WRITE,
+ )
+ .create_query("tag:notify")
+ .search_messages()
+):
+ print(message)
+ message.remove_tag("notify")
+ notify(message.get_header("From"), message.get_header("Subject"))
+ del message