Created
March 1, 2012 19:28
-
-
Save adamwg/1952483 to your computer and use it in GitHub Desktop.
inotify for notmuch
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
# Example: loops monitoring events forever. | |
# | |
import pyinotify | |
from os import system | |
from time import sleep | |
def run_nm(notifier): | |
sleep(1) | |
system("notmuch new") | |
return False | |
# Instanciate a new WatchManager (will be used to store watches). | |
wm = pyinotify.WatchManager() | |
# Associate this WatchManager with a Notifier (will be used to report and | |
# process events). | |
notifier = pyinotify.Notifier(wm) | |
# Add a new watch on /tmp for ALL_EVENTS. | |
wm.add_watch('/home/gordoa4/mail', | |
pyinotify.IN_CREATE | pyinotify.IN_DELETE | | |
pyinotify.IN_MODIFY | pyinotify.IN_MOVE_SELF | | |
pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO, | |
rec=True, auto_add=True, | |
exclude_filter=lambda x: '.notmuch' in x) | |
# Loop forever and handle events. | |
notifier.loop(daemonize=False, callback=run_nm) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment