From: bcstec!hall@uunet.uu.net (Robert J. Hall)
Newsgroups: fj.mail-lists.apollo
Subject: User keyboard activity timeout
Date: 13 Oct 92 17:22:09 GMT
Distribution: fj
Organization: Boeing Computer Services, Seattle


  Thanks to the assistance of some good people on this group, I was able to
put together a successful screen lock program for the HP/Apollo that
incorporated the various features required by my group. I had a request to
post the final code. Unfortunately, due to company restrictions, I'm only
able to post the portion of code responsible for activating the screen lock.
It is listed below in uuencoded format.

  The program is executed as a background process at login. The code polls
for mouse/keyboard events. If no such events are seen within a time interval,
the process activates a procedure (passed as arguements) and waits for it to
terminate. The procedure can be, for example, a screen lock program or a
command to log out the user.

  I'm sure this code can be improved, and I welcome any constructive comments
(via e-mail.) However, I don't plan to provide continual support and updates.

  Thanks,

 Bob Hall,                 | "If at first you don't succeed, try, try again.
 Workstation Peripheral    | Then give up. No use being a damn fool about it."
 Boeing Computer Services  |                                     -Groucho Marx
------------------------------------------------------------------------------
begin 740 timeout.c
M(VUO9'5L92!T:6UE;W5T"B\J+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2T*"@E0
M4D]'4D%-.B!T:6UE;W5T+F,*"@E.3U1)0T4Z(%1H:7,@8V]D92!I<R!#;W!Y
M<FEG:'0@,3DY,B!B>2!T:&4@0F]E:6YG($-O;7!A;GDN"@D)06QL(')I9VAT
M<R!R97-E<G9E9"X*"@E055)03U-%.B!4:&4@5$E-14]55"!P<F]G<F%M(&ES
M(&1E<VEG;F5D('1O(&QO;VL@9F]R(&5V96YT<PH)"69R;VT@=&AE(&UO=7-E
M(&]R(&ME>6)O87)D+B!)9B!N;R!E=F5N=',@87)E('1R86-K960@9'5R:6YG
M"@D)=&AE('1I;65O=70@:6YT97)V86PL('1H92!P<F]C961U<F4@*'!A<W-E
M9"!A<R!A<F=U96UE;G1S"@D)=&\@=&AE('!R;V=R86TI('=I;&P@8F4@97AE
M8W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EV86Q;4T1-7T5#72`]
M(&5C,E\D<F5A9"@@*F5C<%M31$U?14-=("D@*R`Q.PH*"7T*?0H*"B\J+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM"@E-86EN(')O=71I;F4*"@EA<F=C("T@24Y0550@+2!N=6UB
M97(@;V8@87)G=65M96YT<PH)87)G=B`M($E.4%54("T@87)R87D@;V8@87)G
M=65M96YT(&-H87)A8W1E<B!S=')I;F=S"BTM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2HO"@IV;VED
M(&UA:6X@*"!I;G0@87)G8RP@8VAA<B`J87)G=EM=("D*>PH)+RH@26YI=&EA
M;&EZ871I;VX@*B\*"6EN:70H(&%R9V,L(&%R9W8@*3L*"@DO*B!#:&5C:R!F
K;W(@9&ES<&QA>2!E=F5N=',@*B\*"65V96YT7V-H96-K97(H("D["GT*"B!F
`
end
-- 
 Bob Hall,                 | "If at first you don't succeed, try, try again.
 Workstation Peripheral    | Then give up. No use being a damn fool about it."
 Boeing Computer Services  |                                     -Groucho Marx
Newsgroups: fj.mail-lists.apollo