view watch-org.pl @ 18:993b8d7d9bec

buggy garbage
author Robert McIntyre <rlm@mit.edu>
date Wed, 02 Nov 2011 09:24:54 -0700
parents
children
line wrap: on
line source
1 #!/usr/bin/perl
3 use Linux::Inotify2;
4 use WWW::Mechanize::Firefox;
5 my $mech = WWW::Mechanize::Firefox->new();
7 my $inotify = new Linux::Inotify2
8 or die "unable to create new inotify object: $!";
10 $html_files = `find /home/r/proj/{cortex,aurellem,pokemon-types} -name "*.html" -print0`;
11 @html_files = split /\0/, $html_files;
14 #@org_files = glob("./org/*.org");
17 for $file(@html_files){print "$file\n";}
19 $last_page = "";
21 foreach(@html_files){
22 $inotify->watch ($_, IN_MODIFY, sub
23 {
24 my $e = shift;
25 my $name = $e->fullname;
26 print "**************************\n";
27 print "$name was modified\n";## if $e->IN_MODIFY;
29 $path = `readlink -f $name`;
30 $path =~ s|/home/r/proj|http://aurellem.localhost|;
31 #$path =~ s|org|html|g;
33 if ($last_page eq $path){
34 print "reloading current page : $path\n";
35 $mech->reload();
36 }
37 else {
38 print "moving to new page : $path\n";
39 $last_page = $path;
40 $mech->get($path);
41 }
42 });
43 }
45 # manual event loop
46 while (1){
47 print "I'm pollin'!";
48 $inotify->poll;
50 }