view 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
line wrap: on
line source
1 #!/usr/bin/perl
3 use Linux::Inotify2;
4 use AnyEvent;
7 my $inotify = new Linux::Inotify2
8 or die "unable to create new inotify object: $!";
11 @org_files = glob("./org/*.org");
13 $" = "\n";
14 print "@org_files\n";
17 foreach(@org_files){
18 # add watchers
19 $inotify->watch ($_, IN_MODIFY, sub
20 {
21 my $e = shift;
22 my $name = $e->fullname;
23 print "$name was modified\n" if $e->IN_MODIFY;
24 system ("weave $name");
25 print ("$name\n");
26 $path = `readlink -f $name`;
27 $path =~ s|/home/r/proj|http://aurellem.localhost|;
28 print ("$path\n");
29 $path =~ s|org|html|g;
30 print ("$path\n");
31 system ("firefox $path");
33 });
34 }
39 # integration into AnyEvent (works with EV, Glib, Tk, POE...)
40 #my $inotify_w = AnyEvent->io
41 # (
42 # fh => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll }
43 # );
45 # manual event loop
46 1 while $inotify->poll;