Switch to Login Window after specified period of inactivity?

I’ve got FUS enabled, and since this is a family computer used by the entire family, I’d like an applescript that will, after a specified period of inactivity, automatically switch to the login window. Anybody have any ideas here? Google (global and macscripter) turned up nothing.
TIA!

Hi maddys_daddy,
Did you find this thread?

No, but thank you for pointing me in that direction. Option 1 in that thread isn’t acceptable for me (forcing logout after N minutes of inactivity, set in the Security Preference Pane), as I don’t want to log users out, just switch to the login window. However, the script snippet in that thread worked great:

do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -suspend"

So now my question is, how do I script this so that it only does it after N minutes of inactivity?
Thanks!

Hi.

I can’t think of any way to script a check for user activity. But you could set your screen saver to kick in after the required period of inactivity and have a stay-open script running to watch for that.

on idle
	tell application "System Events"
		set screenSaverActive to (application process "ScreenSaverEngine" exists)
	end tell
	if (screenSaverActive) then
		do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -suspend"
	end if
	
	return 15 -- Check every 15 seconds.
end idle