Login out ...

Hi,

I would like to shell script a log out leaving the user has the current user. I know how to permutate to the login window that belongs to «root»:

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

In the security preferences there is a choice that requires to enter a password when the computer as been idle for a certain time period. Is there a way to shell script that choice, meanning that, by script and upon certain conditions, the computer will log out the same way.

Any clue about this one ? Thanks in advance.

Robert Lespérance

Hi,

I’m not sure if this is what you’re looking for, but System Events has a ‘Power Suite’:

eg

tell application "System Events" to log out

Perhaps you’ll find these useful.

Best wishes

John M

Hi John,

Probably the term «log out» is inapropriate. I don’t want to close the user. I want it to stay the frontmost user but protected with a password after a certain amount of idle time.

This state is better describe by refering to the feature available in OS X security system preferences by the «password required after economy suspension or by the screen saver» option (the label of the option has been translated from french an may differ from the actual english version).

Thanks for helping.

Robert

Hi Robert,

Oh, ok. You could probably use System Event’s “Security Suite” then:

tell application "System Events"
	set require password to wake of security preferences to true
end tell

Best wishes

John M

Could this only be available with Leopard ? I am still with Tiger.

That is possible. I could check later.

John M

Yes, it’s only available in Leopard

Hi Stefan,

Is there a way to script that in Tiger ?

Robert

GUI scripting will probably work

this is also a Leopard version, the UI environment of Tiger might be different


tell application "System Preferences"
	activate
	reveal anchor "Advanced" of pane "com.apple.preference.security"
end tell
tell application "System Events" to tell process "System Preferences"
	tell window 1
		tell checkbox "Require password to wake this computer from sleep or screen saver" of tab group 1
			set v to its value
			click
		end tell
		if v = 0 then
			repeat until exists sheet 1
				delay 0.2
			end repeat
			tell sheet 1
				click button "No"
			end tell
		end if
	end tell
end tel

Thanks … I will give it a try.