#!/usr/bin/perl

my $numArgs = @ARGV;
my $host = "";

if ($numArgs == 1) {
    $host = $ARGV[0];
}

my $blanked = 0;
open (IN, "xscreensaver-command -watch |");
while (<IN>) {
    if (m/^(BLANK|LOCK)/) {
	if (!$blanked) {
	    if ($host == "") {
		system("/us/bfsbld/Compilers/distcc/bin/enable-host");
	    } else {
		system("/us/bfsbld/Compilers/distcc/bin/enable-host $host");
	    }
	    $blanked = 1;
	}
    } elsif (m/^UNBLANK/) {
	if ($host == "") {
	    system("/us/bfsbld/Compilers/distcc/bin/disable-host");
	} else {
	    system("/us/bfsbld/Compilers/distcc/bin/disable-host $host");
	}
	$blanked = 0;
    }
} 
