annotate auto-weave.pl @ 8:73beed20f7de

going to move refreshing the page to auto-weave
author Robert McIntyre <rlm@mit.edu>
date Tue, 25 Oct 2011 01:08:31 -0700
parents ce96610fe058
children d09937a6cb4b
rev   line source
rlm@6 1 #!/usr/bin/perl
rlm@6 2
rlm@6 3 use Linux::Inotify2;
rlm@6 4 use AnyEvent;
rlm@6 5
rlm@6 6
rlm@6 7 my $inotify = new Linux::Inotify2
rlm@6 8 or die "unable to create new inotify object: $!";
rlm@6 9
rlm@6 10
rlm@6 11 @org_files = glob("./org/*.org");
rlm@6 12
rlm@6 13 $" = "\n";
rlm@8 14 print "@org_files\n";
rlm@6 15
rlm@6 16
rlm@6 17 foreach(@org_files){
rlm@6 18 # add watchers
rlm@6 19 $inotify->watch ($_, IN_MODIFY, sub
rlm@6 20 {
rlm@6 21 my $e = shift;
rlm@6 22 my $name = $e->fullname;
rlm@6 23 print "$name was modified\n" if $e->IN_MODIFY;
rlm@8 24 system ("weave $name");
rlm@8 25 print ("$name\n");
rlm@8 26 $path = `readlink -f $name`;
rlm@8 27 $path =~ s|/home/r/proj|http://aurellem.localhost|;
rlm@8 28 print ("$path\n");
rlm@8 29 $path =~ s|org|html|g;
rlm@8 30 print ("$path\n");
rlm@8 31 system ("firefox $path");
rlm@8 32
rlm@6 33 });
rlm@6 34 }
rlm@6 35
rlm@6 36
rlm@6 37
rlm@6 38
rlm@6 39 # integration into AnyEvent (works with EV, Glib, Tk, POE...)
rlm@8 40 #my $inotify_w = AnyEvent->io
rlm@8 41 # (
rlm@8 42 # fh => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll }
rlm@8 43 # );
rlm@6 44
rlm@6 45 # manual event loop
rlm@6 46 1 while $inotify->poll;