[comp.windows.x] How to Time Out Inactive Users

lcp@ibism.UUCP (Larry Poleshuck) (01/29/91)

I am writing an application which must time out my users when they have
not touched the keyboard or mouse for a fixed time period, forcing them
to re-enter their password.

One way to do this might be to put in a time-check in the main event loop.
This seems to have quite a large over-head however.  Also, I am using Motif (via TeleUSE) and do not wish to re-write my mainLoop.  

I thought one nice method would be a timeout (every 1 minute or so) which
then looks at the sequence number in the xevent.  If the sequence numbers are sequential, then there has been no activity since the last timeout.  If the timeout generates an xevent.  But I can't figure out how to do this anyway.

Another way might be to send and event (XSendEvent), register an event handler which does nothing but examine the xevent sequence number, etc.  Again, I'm not sure how to do this, or if it will work.

Can anyone think of a good way to solve this problem?  All responses are
greatly appreciated.

-- 

Larry Poleshuck
Citibank
111 Wall Street
New York, NY  10043

Phone:  212-657-7709
Fax:    212-825-8607
E-Mail: uunet!ibism!lcp

fgreco@govt.shearson.COM (Frank Greco) (01/30/91)

> I am writing an application which must time out my users when they have
> not touched the keyboard or mouse for a fixed time period, forcing them
> to re-enter their password.
>
> Can anyone think of a good way to solve this problem?  All responses are
> greatly appreciated.


	How about checking the last access time of /dev/kbd or /dev/mouse?

	I use this little script all the time:

	--------------------------------------------------------------
	#!/bin/sh

	set `ls -lu /dev/mouse`
	mouse=$8

	set `ls -lu /dev/kbd`
	kbd=$8
	set `date`
	time=$4

	echo "Its [$time] - Mouse last touched at $mouse and Keyboard last pressed at $kbd"
	--------------------------------------------------------------


	(Side note: from some tests that I ran, they unexpectedly yielded
	the same time using X11R4, ie, accessing one changed both times,
	but under Sunview I got different times for each)

	Frank G.