Skip to content

Instantly share code, notes, and snippets.

@timothyekl
Created July 27, 2011 15:04
Show Gist options
  • Save timothyekl/1109556 to your computer and use it in GitHub Desktop.
Save timothyekl/1109556 to your computer and use it in GitHub Desktop.
Recompile .tex files based on inotify from Python
import pyinotify
import os
import sys
class Handler(pyinotify.ProcessEvent):
def process_IN_MODIFY(self, event):
if event.name.endswith('.tex'):
print "Recompiling " + event.name + "..."
os.popen('pdflatex ' + event.name).read()
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm, Handler())
wm.add_watch(os.getcwd(), pyinotify.IN_MODIFY)
try:
notifier.loop()
except pyinotify.NotifierError, err:
print >>sys.stderr, err
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment