rlm@6: #!/usr/bin/perl rlm@6: rlm@6: use Linux::Inotify2; rlm@11: use WWW::Mechanize::Firefox; rlm@11: my $mech = WWW::Mechanize::Firefox->new(); rlm@6: rlm@6: my $inotify = new Linux::Inotify2 rlm@6: or die "unable to create new inotify object: $!"; rlm@6: rlm@6: @org_files = glob("./org/*.org"); rlm@6: rlm@6: $" = "\n"; rlm@8: print "@org_files\n"; rlm@6: rlm@9: $ignore_next = 0; rlm@9: rlm@6: rlm@6: foreach(@org_files){ rlm@6: # add watchers rlm@6: $inotify->watch ($_, IN_MODIFY, sub rlm@6: { rlm@9: print ("IGNORE : $ignore_next\n"); rlm@15: # ok, for some reason this gets called exactly rlm@9: # twice every time the file is saved from emacs. rlm@9: # so ignore every other invocation. rlm@9: if ($ignore_next) { rlm@9: $ignore_next = 0; rlm@9: return; rlm@9: } rlm@13: $ignore_next = 1; rlm@9: rlm@9: my $e = shift; rlm@9: my $name = $e->fullname; rlm@9: print "$name was modified\n" if $e->IN_MODIFY; rlm@9: $output = `weave $name`; rlm@9: $path = `readlink -f $name`; rlm@9: $path =~ s|/home/r/proj|http://aurellem.localhost|; rlm@9: $path =~ s|org|html|g; rlm@11: $mech->get($path); rlm@6: }); rlm@6: } rlm@6: rlm@6: rlm@13: # manual event loop rlm@6: 1 while $inotify->poll;