Listing 1: Background monitor script
#!/bin/sh
#
# Command: lock=<screenlock> monitor <secs> &
#
# Monitor keyboard and mouse activity and execute <screenlock> when no
# activity has occurred in the last <secs> seconds
#
# Calls: <OS>_kbr for keyboard interrupts/counts
# <OS>_msr for mouse interrupts/counts
#
# Note: <OS> is the operating system as returned by uname
#
# Programmer: Doug Morris 1/17/96
#
# determine count routine names
os=`uname`
kbr=${os}_kbr
msr=${os}_msr
exit=N
# loop until terminated
while [ $exit = N ]
do
# get current keyboard & mouse activity counts
kbo=`$kbr`
mso=`$msr`
# sleep for specified period
sleep $1
# get updated keyboard & mouse activity counts
kbn=`$kbr`
msn=`$msr`
# if no keyboard or mouse activity occurred call <screenlock>
if [ $kbo -eq $kbn -a $mso -eq $msn ]
then $lock
fi
done
# End of File
|