Skip to content

Instantly share code, notes, and snippets.

@kbingham
Created October 29, 2021 19:20
Show Gist options
  • Save kbingham/7bffd666a7a20bc974becec90c4872e2 to your computer and use it in GitHub Desktop.
Save kbingham/7bffd666a7a20bc974becec90c4872e2 to your computer and use it in GitHub Desktop.
[bindings]
G = call hooks.getmail(ui)
## 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)
@kbingham
Copy link
Author

kbingham commented Oct 29, 2021

'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