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.
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).
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