Created
October 29, 2021 19:20
-
-
Save kbingham/7bffd666a7a20bc974becec90c4872e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[bindings] | |
G = call hooks.getmail(ui) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## https://github.com/pazz/alot/wiki/Contrib-Hooks#getting-new-msg-while-alot-is-running | |
## Addition to communicate and notify stdout by Kieran Bingham | |
## Displays stdout of the fetched mail process, but hangs the UI while waiting for it to complete. | |
def getmail(ui=None): | |
ui.notify("fetching email..") | |
msg=subprocess.Popen("notmuch new".split(),stdout=subprocess.PIPE,stderr=subprocess.PIPE) | |
stdout, stderr = msg.communicate() | |
ui.notify(stdout) |
'notmuch new' calls into other hooks to get my mail through mbsync/lore and synchronise patchwork, as well as handle tagging with afew.
$ cat ~/Mail/.notmuch/hooks/pre-new
#!/bin/sh
# Fetch mail
mbsync -a
# Hooking lore updates
echo "Syncing from Lore"
~/Mail/.notmuch/.lore/hooks/pre-new
$ cat ~/Mail/.notmuch/hooks/post-new
#!/bin/sh
echo "Synchronise patchwork"
pwnm-sync.py
# Resync imap folders
mbsync -a
# Handle tagging
afew --tag --new
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Though that is both stdout, and stderr
Stdout is just