Mercurial > org-tools
view auto-weave.pl @ 14:7d7f76b78e33
functional automatic browser refresh
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 25 Oct 2011 08:12:00 -0700 |
parents | be73e58d4b24 |
children | 6ef9ccf7a17e |
line wrap: on
line source
1 #!/usr/bin/perl3 use Linux::Inotify2;4 use WWW::Mechanize::Firefox;5 my $mech = WWW::Mechanize::Firefox->new();7 my $inotify = new Linux::Inotify28 or die "unable to create new inotify object: $!";10 @org_files = glob("./org/*.org");12 $" = "\n";13 print "@org_files\n";15 $ignore_next = 0;18 foreach(@org_files){19 # add watchers20 $inotify->watch ($_, IN_MODIFY, sub21 {22 print ("IGNORE : $ignore_next\n");23 # ok, for some reason this get's called exactly24 # twice every time the file is saved from emacs.25 # so ignore every other invocation.26 if ($ignore_next) {27 $ignore_next = 0;28 return;29 }30 $ignore_next = 1;32 my $e = shift;33 my $name = $e->fullname;34 print "$name was modified\n" if $e->IN_MODIFY;35 $output = `weave $name`;36 $path = `readlink -f $name`;37 $path =~ s|/home/r/proj|http://aurellem.localhost|;38 $path =~ s|org|html|g;39 $mech->get($path);40 });41 }44 # manual event loop45 1 while $inotify->poll;