From 5bf571df14cd2ed7cf6ca6ecadc26da53d61af06 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Wed, 15 May 2024 20:03:30 -0500 Subject: feat(mail): move all mail stuff inside notmuch hooks --- notmuch/.local/bin/notmuch-notify | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 notmuch/.local/bin/notmuch-notify (limited to 'notmuch/.local/bin') 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 -- cgit v1.2.3-70-g09d2