comparison watch-org.pl @ 18:993b8d7d9bec

buggy garbage
author Robert McIntyre <rlm@mit.edu>
date Wed, 02 Nov 2011 09:24:54 -0700
parents
children
comparison
equal deleted inserted replaced
17:6da973a6b93d 18:993b8d7d9bec
1 #!/usr/bin/perl
2
3 use Linux::Inotify2;
4 use WWW::Mechanize::Firefox;
5 my $mech = WWW::Mechanize::Firefox->new();
6
7 my $inotify = new Linux::Inotify2
8 or die "unable to create new inotify object: $!";
9
10 $html_files = `find /home/r/proj/{cortex,aurellem,pokemon-types} -name "*.html" -print0`;
11 @html_files = split /\0/, $html_files;
12
13
14 #@org_files = glob("./org/*.org");
15
16
17 for $file(@html_files){print "$file\n";}
18
19 $last_page = "";
20
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;
28
29 $path = `readlink -f $name`;
30 $path =~ s|/home/r/proj|http://aurellem.localhost|;
31 #$path =~ s|org|html|g;
32
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 }
44
45 # manual event loop
46 while (1){
47 print "I'm pollin'!";
48 $inotify->poll;
49
50 }