Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Switch to login window upon sleep' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Switch to login window upon sleep
Authored by: bharley on Jan 11, '09 01:39:45AM
came up with a solution for locking the screen on sleep but not with the screensaver.

i found a way around the fact that if you call 'CGSession -suspend' as root, the Window server acts very strange (losing the application switcher and the Exposť keys), and that if you try to do it as a user, the system recognizes that you are not in control of the console at that moment, and refuses to suspend.

i use a ~/.sleep script that calls an applescript to turn on the 'require password to wake from screensaver or sleep' option, and then launch the screensaver, which kicks in the new preference, which otherwise doesn't work if the machine just goes to sleep. then there is a ~/.wakeup script that turns it back off, so the user isn't bothered with needing a password when the screensaver kicks in.

the script is a little more sophisticated, because it checks to see if the use of the password is already on. if so, then it doesn't need to create a .wakeup script to turn it off. so there is a .wake script that is copied to .wakeup by the .sleep script only if password wasn't already on.

finally, a small modification to the rc.sleep file has it only launch the .sleep command for the user who is actively using the console. this way you place the proper .sleep / .wake commands in every user account that you want to be protected when they are using the computer before it sleeps - but you don't have problems with the script launching twice in a row if there are two or more such users logged in at the same time. if one of those users is not logged on - presumably it doesn't matter if the screen isn't locked for sleep, since someone would need to know the password for those accounts to get to them at that point.

a little complicated, but it works. for the moment, i have placed the scripts in a zip file that can be downloaded

remember three of the files are .files, so invisible without doing an ls -a.

rc.sleep => goes in /etc (requires root ownership and executability)
.sleep => goes in the user's home folder ~ (should be owned by user and executable)
.wake => ditto
.sleep_ascript => ditto

[ Reply to This | # ]