#!/afs/athena/contrib/perl/perl

$startime = time;
%ACT = ('m', 'Reading and Sending Mail',
	'd', 'Using Discuss',
	'n', 'Netnews',
	'z', 'Zephyr',
	'p', 'Perl stuff',
	'u', 'UROP',
	'a', 'Away from the machine',
	's', 'SIPB stuff',
	'o', 'OLCR',
	'c', 'Class Work',
	'h', 'Hacking (not perl)',
	'e', 'Elvhs list maintenance',
	'g', 'Playing Games',
	'w', 'Wasted',
	'f', 'File management',
	'l', 'Logging activities',
	'x', 'Other');

$pid = fork();

if(!$pid){
while(1){
sleep(1000);
&zme();
}
}
else{
open(LG, ">/tmp/activitylog");
print(LG "$startime\n");
close(LG);
$lls = `tail -1 /mit/$ENV{'USER'}/Other/usage`;

@bits = split(',', $lls);
$lhost = $bits[0];
$ltime = $bits[1];
int($ltime);
print("L: $ltime\n");
foreach $i (2..$#bits-1){
	$actype = $bits[$i];
	$actype =~ s/\d//g;
	$actdur = $bits[$i];
	$actdur =~ s/\D//g;
	$actdur = int($actdur);
	$perc = int(100*$actdur/($ltime));
	$usage .= "$actdur minutes -($perc%)- $ACT{$actype}\n";
}


	print("---------------------------\n");
	print("Last Login Session Summarry\n");
	if($ltime > 60){
		$lhours = $ltime/60;
		$lhours = int($lhours);
		$actdur = $ltime%60;
	}
	print("Total time: ");
	print("$lhours hour(s), ") if $lhours;
	print("$actdur minutes.\n");
	print($usage);
}


sub zme {
        open (ZME, "|zwrite -n -q -d -s 'AutoReminder' $ENV{'USER'}");
        print(ZME "Make a log entry ($$)");
        close(ZME);
}

