rlm@6: #!/usr/bin/perl rlm@6: rlm@6: use Linux::Inotify2; rlm@6: use AnyEvent; rlm@6: rlm@6: rlm@6: my $inotify = new Linux::Inotify2 rlm@6: or die "unable to create new inotify object: $!"; rlm@6: rlm@6: rlm@6: @org_files = glob("./org/*.org"); rlm@6: rlm@6: $" = "\n"; rlm@8: print "@org_files\n"; rlm@6: rlm@6: rlm@6: foreach(@org_files){ rlm@6: # add watchers rlm@6: $inotify->watch ($_, IN_MODIFY, sub rlm@6: { rlm@6: my $e = shift; rlm@6: my $name = $e->fullname; rlm@6: print "$name was modified\n" if $e->IN_MODIFY; rlm@8: system ("weave $name"); rlm@8: print ("$name\n"); rlm@8: $path = `readlink -f $name`; rlm@8: $path =~ s|/home/r/proj|http://aurellem.localhost|; rlm@8: print ("$path\n"); rlm@8: $path =~ s|org|html|g; rlm@8: print ("$path\n"); rlm@8: system ("firefox $path"); rlm@8: rlm@6: }); rlm@6: } rlm@6: rlm@6: rlm@6: rlm@6: rlm@6: # integration into AnyEvent (works with EV, Glib, Tk, POE...) rlm@8: #my $inotify_w = AnyEvent->io rlm@8: # ( rlm@8: # fh => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll } rlm@8: # ); rlm@6: rlm@6: # manual event loop rlm@6: 1 while $inotify->poll;