Mercurial > org-tools
view watch-org.pl @ 24:7b34b718503e tip
makefile, and updated this stuff to work with the newest emacs!
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 02 Mar 2015 12:30:24 -0800 |
parents | 993b8d7d9bec |
children |
line wrap: on
line source
1 #!/usr/bin/perl3 use Linux::Inotify2;4 use WWW::Mechanize::Firefox;5 my $mech = WWW::Mechanize::Firefox->new();7 my $inotify = new Linux::Inotify28 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, sub23 {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 loop46 while (1){47 print "I'm pollin'!";48 $inotify->poll;50 }