#!/usr/bin/perl use Term::ReadKey; $basedir = "$ENV{HOME}/gtd"; $actions = "${basedir}/\@actions"; $postponed = "$ENV{HOME}/mail/postponed"; $minutes = 0; while (true) { $dirswithactions = 0; $minutes++; @actiondirs = `find ${actions} -type d`; foreach $dir ( sort @actiondirs ) { chomp $dir; $dirname = $dir; $dirname =~ s[${actions}/(.*)][$1]; $actionsindircount = `find ${dir} -maxdepth 1 -type f | wc -l`; chomp $actionsindircount; if ( $actionsindircount > 0 ) { print "\n\nwork on ${dirname}.\n"; $dirswithactions++; countdown(); } } @mboxes = `find $ENV{HOME}/mail/incoming -type f`; foreach $mbox ( sort @mboxes ) { chomp $mbox; if ( -s $mbox ) { print "\n\nprocess ${mbox}\n"; $dirswithactions++; countdown(); } } if ( -s $postponed ) { print "\n\nwork on postponed email messages.\n"; $dirswithactions++; countdown(); } if ( $dirswithactions == 0 ) { quit("no tenmins!"); } else { print "\n\nread things in ~/gtd/read/\n"; countdown(); } } sub getkey { ReadMode 'cbreak'; $key = ReadKey(0); ReadMode 'normal'; } sub countdown { $countdown = system( "$ENV{HOME}/bin/countdown", "${minutes}", '0' ); if ( $countdown == 0 ) { system( 'xmessage', '-geometry', '640x480', '-buttons', 'ok', '-default', 'ok', 'stop.' ); } print "\npress any key to continue."; getkey(); } sub quit { print "whoops! $_[0]:\n $!\n"; die; }