diff options
Diffstat (limited to 'notmuch/.local/bin/notmuch-notify')
-rwxr-xr-x | notmuch/.local/bin/notmuch-notify | 34 |
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 |