Skip to content

Instantly share code, notes, and snippets.

@kbingham
Created October 29, 2021 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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

C: 1/1 B: 13/13 M: +0/0 *0/0 #0/0 S: +0/0 *0/0 #0/0
Syncing from Lore
linux-renesas-soc: initialize (https://lore.kernel.org/linux-renesas-soc)
epoch0: syncing
linux-media: initialize (https://lore.kernel.org/linux-media)
epoch0: syncing
No new mail.
Synchronise patchwork
/home/kbingham/bin/pwnm-sync.py:59: DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.
config = configparser.SafeConfigParser()
Looking at project libcamera (id 1)
Going to look at things post 2021-06-21 03:41:18
Processed 250 libcamera patches...
Processed 500 libcamera patches...
Processed 750 libcamera patches...
Processed 1000 libcamera patches...
Processed 1250 libcamera patches...
Processed 1500 libcamera patches...
Processed 1540 libcamera patches...
Finished processing 1540 libcamera patches!
{}
C: 1/1 B: 13/13 M: +0/0 *0/0 #0/0 S: +0/0 *0/0 #0/0

@kbingham
Copy link
Author

Though that is both stdout, and stderr
Stdout is just

Syncing from Lore
No new mail.
Synchronise patchwork
Looking at project libcamera (id 1)
Going to look at things post 2021-06-21 03:41:18
Processed 250 libcamera patches...
Processed 500 libcamera patches...
Processed 750 libcamera patches...
Processed 1000 libcamera patches...
Processed 1250 libcamera patches...
Processed 1500 libcamera patches...
Processed 1540 libcamera patches...
Finished processing 1540 libcamera patches!
{}

@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