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

Switch to login window upon sleep System
As the proud owner of a new 12" powerbook, I immediately wanted one feature lacking in Mac OS X: the ability to have a secure screen lock upon closing the lid. There has been some discussion on this site of how to "fast user switch" to the login screen on screensaver activation, but this wasn't really what I was looking for. When the screensaver is on, I can be reasonably sure I'm near my notebook. But when I close it, drop it in its case, and head out -- that's when we could get separated.

Looking through this site, I found part of the solution in this hint. The trick was getting this script to activate on Sleep (or wake up). After some searching, I found Bernhard Baehr's excellent Sleepwatcher. Sleepwatcher is a daemon that calls a pair of scripts, ~/.sleep and ~/.wakeup, upon sleep and wakeup. Combining these two, I installed Sleepwatcher, and used the code below as my .sleep file (the /System... line is shown on two lines; enter it as one line without any added spaces):
#!/bin/sh
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/
 Resources/CGSession -suspend
Restart, and your Mac will fast-user switch itself to the log in screen when you close the lid! Hope this helps other paranoid PowerBook owners! Note: You can also put this script in your .wakeup file, but there's a few (three to five) seconds' delay between wake and the script call, leaving the system wide open for a few seconds, and looking a bit tacky to boot.

[robg adds: I tested this one with our iBook, and it worked exactly as described. Make sure you remember to make the script executable (chmod +x .sleep). It's pretty cool; close the lid, and next time you open it, you're at the login screen, but still logged in thanks to fast user switching.]
    •    
  • Currently 3.40 / 5
  You rated: 1 / 5 (5 votes cast)
 
[46,527 views]  

Switch to login window upon sleep | 62 comments | Create New Account
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: Paul_Willis on Jul 28, '04 11:35:16AM

This is built in to OS X (a least in 10.3). In "System Preferences", choose the "Security" icon, check "Require password to wake this computer from sleep or screen saver"

or am I missing something?



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: rhowell on Jul 28, '04 12:07:48PM
If you require a password when the computer wakes, any Admin password will do. Forcing the system back to the login window will require your password only to get back to your session.

But you're right, since the intention is to keep thieves from accessing your account, enabling "Require password to wake this computer from sleep or screen saver" will do the trick. They don't have an admin password.

[ Reply to This | # ]
Switch to login window upon sleep
Authored by: Dahak on Jul 28, '04 12:08:00PM

Password protected wake-from-sleep is built into 10.3, but from my perspective it suffers from two drawbacks:

1. You can unlock the screen using any admin login and password on the Mac.

2. If you're set up as a Mobile User, where your login checks for an Open Directory server for authentication before falling back on cached credentials, your PowerBook may fall back asleep several times before the password screen even comes up.

With this hint, switching to the login screen allows you the security of knowing that only your login and password will unlock your session.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: derrickbass on Jul 28, '04 07:34:33PM

That's precisely the point. The checkbox makes you authenticate on wake-from-sleep AND the screensaver. I've always found that annoying. I only want to authenticate on wake-from-sleep. (Actually, what I really want is my screensaver to come on after 10 minutes, but I want the password dialog only if I'm away for an hour.)

Oh, and to those of you who are worried about other admin users being able to get into your account from the standard password dialog... you may want to rescind their administrator access. They already have the ability to access everything in your account, change your password, format your disk, do screen captures to spy on you, whatever. If you don't trust them not to abuse this power, they shouldn't be administrators.

In fact, I wish there were a way for an administrator to get into other accounts from the login screen. It's awfully frustrating when you need to reboot but there is someone else logged in. You have no good way of knowing whether killing their session will cause them to lose work or corrupt their preferences or whatever. (Of course, these days there is absolutely no excuse for programs to lose data when they are killed, but programs that have this feature are nevertheless few and far between.)



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: mzarra on Jul 28, '04 11:50:19AM

Very nice tip! I was able to hook it into Sailing's Clicker so that when I walk away from my machine it automatically goes to the login screen.

Very helpful.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: paulio on Jul 28, '04 11:53:57AM
The correct command is:
chmod +x .sleep
It is case sensitive.

[ Reply to This | # ]
Switch to login window upon sleep
Authored by: robg on Jul 28, '04 05:54:31PM

Whoops; sleepy fingers make stupid typos. Thanks for spotting it; it's fixed now.

-rob.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: dogboy on Jul 28, '04 12:18:24PM
This is way more secure than just the screensaver protection. 10.3 allows events through the password dialog: When my screensaver is active and the dialog is waiting for my password, Salling clicker events are let through, so I can check my mail, control itunes or, crucially, run any script. I don't really have a problem with that on my home machine, but your solution seems to be a good one.

[ Reply to This | # ]
Switch to login window upon sleep
Authored by: kgarner on Jul 28, '04 12:27:42PM

Can this be adapted to swith to a particular User on sleep? I would like to switch to my son's account when it goes to sleep so that if he comes along and wants to play he can with out screwing anything up.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: pjw on Jul 28, '04 03:30:47PM
Sure, just use this line:
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/
Resources/CGSession -switchToUserID yourson
where yourson is your son's user id. That's all one line, by the way.

[ Reply to This | # ]
Switch to login window upon sleep
Authored by: kgarner on Jul 28, '04 03:32:52PM

As always, it is simpler than I think it is. Thank you so much.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: fbitterlich on Jul 28, '04 12:51:07PM

For some reason it doesn't work for me... sleepwatcher is running (checked with "ps -ax"), my ~/.sleep is "chmod +x" (I can run it manually, and I can also run /etc/rc.sleep manually), but when my PowerBook goes to sleep (manually, or by closing the lid), it doesn't run the .sleep script. Any ideas?



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: Dahak on Jul 28, '04 01:29:33PM

What model PowerBook do you have? I just set this up on a 15" Aluminum PB and it works great.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: fbitterlich on Jul 29, '04 06:53:20AM
That's a 12" Al. It appears to be a permissions problem; when I change the "rc.login" script from this...

for home in /var/root /Users/*; do
        if [ -f "$home/.sleep" -a -x "$home/.sleep" ]; then
               su - `basename "$home"` -c "$home"/.sleep
        fi
done
... to this...

for home in /var/root /Users/*; do
        if [ -f "$home/.sleep" -a -x "$home/.sleep" ]; then
                "$home"/.sleep
        fi
done
..., then it works. Looks like it chokes on the "su" command... If I do that line manually, it asks for a passsword.

[ Reply to This | # ]
Switch to login window upon sleep
Authored by: beanboyrjs on Jul 29, '04 10:37:16AM

That worked! Thanks



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: whatevrnvrmind on Jul 30, '04 09:13:51PM

I'm a little bit of a newbie. Can you be a little more specific on how to locate this file and edit it?



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: beanboyrjs on Jul 28, '04 11:26:26PM

This isn't working for me either. I have a 15" TiBook, and have made the same checks.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: whatevrnvrmind on Jul 29, '04 02:26:01AM

Not working for me either. I have a PowerBook G4/1.25 GHz.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: habes on Jul 28, '04 01:36:37PM

Along the same lines, is it possible to prevent a PowerBook from going to sleep when you close the lid? This would be useful, for example, when I have video playing on a separate monitor or TV, and I don't need to have the computer open.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: pub3abn on Jul 28, '04 02:24:09PM

According to various reports, running a PB with the lid closed could lead to serious over-heating issues, potentially frying your precious system.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: mzarra on Jul 28, '04 08:35:17PM

That may be true on the ibook models but even Apple's own manual that comes with the powerbook describes how to do this. I doubt running a powerbook with the lid closed would damage it. I do it fairly often and have had no adverse effects over the past year.

The answer is simple. Connect an external mouse or keyboard to the powerbook, let it go to sleep then either move the mouse or touch the keyboard and the powerbook will wake back up. Naturally you want a monitor connected as well :)



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: MattHaffner on Jul 29, '04 12:21:45AM

Heat problems are an issue only for the PB G3, IIRC.

For a PB G4, that's only a problem if you run it with the lid closed and the screen *on*. There are some hacks to do this (e.g. KisMAC), but it's not a good idea.

As the poster above notes, PowerBook G4's were designed to run without the lid open if you have an external monitor, keyboard and/or mouse, and the power cord all attached. See KB #88064 for example.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: pjw on Jul 28, '04 03:32:41PM

Go search VersionTracker.com for a program called Sleepless that does what you need. But beware of the overheating problem.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: PeteVerdon on Aug 15, '04 10:09:56AM

Assuming you have a G4 Powerbook:

1. Read your instruction manual. It explains exactly how to do this.
2. Will everyone please shut up about overheating? Would Apple devote two pages of the manual to closed-lid running if it was likely to damage the machine? This was an issue on older models that dissipated heat from under the keyboard; current Powerbooks use the bottom of the case as a heatsink instead.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: pairof9s on Jul 28, '04 01:43:31PM

I never know how to do these things!

Can someone help a "newbie" get this going? How do you even edit the .sleep script?

TIA



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: aixccapt99 on Jul 28, '04 04:17:43PM

1) Open the Terminal application.

2) Type:
cd
and press return.

3) Type:
pico .sleep
and press return. A simple text editor will run and you can edit the .sleep file. The save command is ctrl-o, and the exit command is ctrl-x.



[ Reply to This | # ]
not quite a daemon
Authored by: KWillets on Jul 28, '04 01:56:00PM

I was worried that this thing had a big security hole in it, but I realized it was my confusion over the description of the tool.

This is a background process that runs under the userid of the person that runs it; it's not a root-level daemon that serves all users. It might be nice to have a cron-type sleep/wakeup event daemon at the admin level, but this isn't it (although it could be run by root).



[ Reply to This | # ]
not quite a daemon
Authored by: jecwobble on Jul 29, '04 01:17:35PM

Are you sure? If the StartupItem that comes with it is used, wouldn't that be run at startup as root?

That might be the problem with people trying to run the rc.sleep and rc.wakeup files. The su command doesn't need a password if run as root to begin with. I use it in a root ran script to su to a regular user and it works fine.



[ Reply to This | # ]
not quite a daemon
Authored by: KWillets on Jul 29, '04 02:12:49PM

OK, I looked at rc.sleep and it implements some systemwide functionality. The SleepWatcher process in this case runs as root and polls /Users/* and /var/root for .sleep and .wakeup files, and executes each while su'ed to the directory name (!) where the file is found, eg /Users/bob/.sleep is run as "bob", whether that user exists or not.

The su step alleviates at least my concern over running arbitrary .sleep files as root. I would recommend a bit more attention to how user directories are found - for instance Oracle, etc. accounts often have non-/Users home directories. /Users/Shared also seems to pose a problem as well, although it will probably just error out unless a username of "Shared" exists.

Unfortunately I have not yet figured out how or where user information is hidden on OS X, so I can't say how to improve this.



[ Reply to This | # ]
SleepWatcher + WinSwitch?
Authored by: ksars on Jul 28, '04 07:43:39PM

Anyone figure out how to get this to work with WinSwitch instead of the standard Apple FUS menu item?

-cs



[ Reply to This | # ]
SleepWatcher + WinSwitch?
Authored by: ksars on Jul 28, '04 07:59:49PM

duh, nevermind - it still works fine even if apple's FUS menu isn't on.

that'll teach me to test before posting ... hehehe



[ Reply to This | # ]
External monitor problem and hack
Authored by: DylanMuir on Jul 29, '04 04:26:17AM
I have an external monitor connected to my Powerbook 12", which I use in conjunction with the laptop screen. Using this script worked fine for me, dropping out to the FUS login window when falling asleep. However, when I woke the machine up and logged in, the external monitor would not 'recover' from the blue sleep screen.

Forcing 'detect displays' in System Preferences didn't recover the screen, nor did unplugging the video cable and reconnecting! But I noticed that when I used the Apple FUS menu to manually drop back to the FUS login window, I didn't have this problem.

I don't know the cause, but I found that adding

sleep 4
to the end of the .sleep script stopped it from happening.

Any ideas as to the cause, and a proper solution instead of this silly hack?

DRM

[ Reply to This | # ]

External monitor problem and hack
Authored by: neosputnik on Jul 29, '04 03:11:59PM

I have a 15 inch Titanium Powerbook and have experienced a variant of this problem.

At work I have an external monitor connected to my PowerBook. At home, I use the laptop without an external monitor. When I took my system home and woke it from sleep, the screen recognized the fact that there was no external monitor, but all of the applications with windows formerly on the external monitor became "ghosts". I could see them in Expose, but I couldn't make them visible on the main screen. The "ghost" of the external monitor continued to appear in the display menu, and Detect Displays did nothing...

I'll try the sleep 4 command and see if that hack works for me as well... but it woud be great to understand how to make this work right.

Great hint, by the way!



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: ozzyrules on Jul 29, '04 10:24:04AM

I think it would be useful to make sure you have an openfirmware password as well. Otherwise anyone with a OS install disk can reset the password. It might also be helpful to disable the restart button in the log in screen.



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: andrep on Jul 30, '04 05:22:56AM

I'm experiencing strange behaviour when the machine wakes from sleep, using this hint. Occasionally, the login window seems to lock up - I can enter exactly four characters of my password. On typing the fifth character, the machine beeps, and the login window then refuses to accept any further input. Oddly, the little black bullets that indicate character entry in the password field also fail to appear. This seems to happen at random, and when it does, the only solution seems to be to hit the power button, :-(

It looks as if something is not being iitialised correctly on wake-up. I am running some additional preferences (uControl, SideTrack), but these work fine under normal circumstances. Will post again if I find the cause.



[ Reply to This | # ]
Undoing this script
Authored by: ashuttleworth on Jul 30, '04 09:18:05AM

I like the hint a lot, but now that I've done it, I'd like to be able to undo it. Can someone walk me through how to do so? (I don't simply want to get rid of the "sleep" script, I want to get rid of the sleepwatcher daemon, as well.)

Thanks for any help.



[ Reply to This | # ]
Undoing this script
Authored by: andrep on Jul 30, '04 07:49:36PM
You'll need to do this from Terminal's command line::

1/. Delete the .sleep script from your home directory:

cd
rm .sleep

Then, do the remaining commands, as root:

2/. Shut down the sleepwatcher daemon:

/Library/StartupItems/SleepWatcher/Sleepwatcher stop

3/. Delete the sleepwatcher daemon itself:

rm /usr/local/sbin/sleepwatcher

4/. Remove the sleepwatcher startup script:

rm -rf /Library/StartupItems/SleepWatcher

That should be it.

[ Reply to This | # ]

Undoing this script
Authored by: andrep on Jul 30, '04 08:05:49PM
Apologies, that was too hasty!

You'll also want to get rid of rc.sleep and rc.awake as well:

rm /etc/rc.sleep
rm /etc/rc.awake


[ Reply to This | # ]

Switch to login window upon sleep
Authored by: 2peak on Jul 31, '04 08:24:17AM

I was wondering, if this also works on 'normal' desktop computers too?
because I followed all the instructions and it doesn't seem to work! (posted a thread on the forum about this too)



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: jamiebah on Aug 02, '04 10:27:02PM
I needed to add a bit to the /etc/rc.sleep script, it didn't work if I added it to the .sleep script. (The line I added is in BOLD) If I didn't, I would get errors in the system log file that looked like this after waking my laptop
NPC (kext): Unable to send disconnect message to npcdaemon (32)

for home in /var/root /Users/*; do
 if [ -f "$home/.sleep" -a -x "$home/.sleep" ]; then
    su - `basename "$home"` -c "$home"/.sleep
   sleep 3
  fi
done


[ Reply to This | # ]
Can't type at the login
Authored by: windup_bird7 on Aug 12, '04 11:54:58AM

I've started to not be able to type anything on the login window after my iBook (Dual USB) wakes up, perhaps after the 10.3.5 update (though I'm not sure if that is the cause). Is there anyone experiencing this?



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: Bennyp on Aug 21, '04 06:14:30PM

This is a good method, but I find it to be very slow. On my iBook G4 with 256 megs of ram, it takes a good 10 seconds from the time i open the lid to when i can type my password in!!
I would like to know how i can either speed up this process, or use another, quicker method to password lock my machine when i close it's top.



[ Reply to This | # ]
Problems after 10.3.5
Authored by: derekhed on Sep 09, '04 04:33:33PM
On a 15" TiBook, with 1 Gig RAM, running 10.3.5...

Well, I am not certain that it is related to upgrading to 10.3.5, but I was not able to wake my 15" Ti from sleep after the first time. In fact, it appeared that the machine never made it to sleep since the glowing light never came one.

FWIW, my system.log excerpt is below. Note the successful wake, then the next sleep command, followed by the hard reboot. I went through this sequence several times, each time trying to eliminate another variable. I have since removed all traces of sleepwatcher from my machine, and my machine is acting normal again. But I miss some of the functionality. :-(

Sep  9 10:45:27 localhost kernel: [HCIController][RequestPowerStateChange] 1->0
Sep  9 10:45:27 localhost kernel: [HCIController][RequestPowerStateChange] sleep is not available
Sep  9 10:45:27 localhost kernel: [HCIController][RequestPowerStateChange] sleep is not enabled
Sep  9 10:45:27 localhost kernel: [HCIController][RequestPowerStateChange] Calling changePowerStateTo(0)
Sep  9 10:45:27 localhost kernel: [HCIController][setPowerState] 0 (ignore=0)
Sep  9 10:45:28 localhost kernel: [HCIController][setPowerStateWL] 0
Sep  9 10:45:28 localhost kernel: [HCIController][PerformPowerStateChange] 1->0
Sep  9 10:45:28 localhost kernel: [AppleUSBHCIController][StopIsochPipeRead] - mInt1IsochInPipe = 0 - numReadsPending = 0
Sep  9 10:45:28 localhost kernel: [HCIController][CompletePowerStateChange]
Sep  9 10:45:28 localhost kernel: [HCIController][RequestPowerStateChange] changePowerStateTo() returned 0x0
Sep  9 10:45:28 localhost kernel: [HCIController][RequestPowerStateChange] changePowerStateTo(0) returned 0x0
Sep  9 10:45:38 localhost /System/Library/Extensions/IOSerialFamily.kext/Contents/PlugIns/InternalModemSupport.kext/Contents/Resources/AppleModemOnHold.app/Contents/MacOS/AppleModemOnHold: ModemOnHoldOpen >> 
Sep  9 10:45:38 localhost /System/Library/Extensions/IOSerialFamily.kext/Contents/PlugIns/InternalModemSupport.kext/Contents/Resources/AppleModemOnHold.app/Contents/MacOS/AppleModemOnHold: MOHServiceAddedProc >> 
Sep  9 10:45:38 localhost /System/Library/Extensions/IOSerialFamily.kext/Contents/PlugIns/InternalModemSupport.kext/Contents/Resources/AppleModemOnHold.app/Contents/MacOS/AppleModemOnHold: MOHServiceAddedProc <<< 
Sep  9 10:45:42 localhost kernel: at_obdev_KUC: at_obdev_KUC_UserClient::setDebugEnabled(0)
Sep  9 10:45:42 localhost kernel: at_obdev_KUC: at_obdev_KUC_UserClient::debug log disabled
Sep  9 10:46:57 localhost mDNSResponder[227]: mDNSResponder Sleeping at 262979
Sep  9 10:46:58 localhost /usr/local/sbin/sleepwatcher: sleep: /etc/rc.sleep: 0 
Sep  9 10:46:59 localhost kernel: AppleNMI mask NMI
Sep  9 10:46:59 localhost configd[136]: AppleTalk shutdown
Sep  9 10:46:59 localhost configd[136]: AppleTalk shutdown complete
Sep  9 10:47:52 localhost kernel: System Sleep
Sep  9 10:47:53 localhost kernel: System Wake
Sep  9 10:47:53 localhost kernel: Wake event 0020
Sep  9 10:47:53 localhost kernel: AppleNMI unmask NMI
Sep  9 10:47:53 localhost kernel: ADB present:8c
Sep  9 10:47:53 localhost kernel: Sound assertion "0 == mLineInDetectIntProvider" failed in "AppleOnboardAudio/KeyLargoPlatform.cpp" at line 1212 goto Exit
Sep  9 10:47:53 localhost kernel: Sound assertion "1" failed in "AppleOnboardAudio/PlatformInterface.cpp" at line 143 goto handler
Sep  9 10:47:53 localhost kernel: 
Sep  9 10:47:53 localhost kernel: UniNEnet::monitorLinkStatus - Link is up at 100 Mbps - Full Duplex
Sep  9 10:47:53 localhost configd[136]: AppleTalk startup
Sep  9 10:47:54 localhost mDNSResponder[227]: mDNSResponder Waking at 269304
Sep  9 10:47:54 localhost /usr/local/sbin/sleepwatcher: wakeup: /etc/rc.wakeup: 0 
Sep  9 10:47:59 localhost configd[136]: AppleTalk startup complete
Sep  9 10:48:00 localhost kernel: [HCIController][RequestPowerStateChange] 0->1
Sep  9 10:48:00 localhost kernel: [HCIController][RequestPowerStateChange] sleep is not available
Sep  9 10:48:00 localhost kernel: [HCIController][RequestPowerStateChange] sleep is not enabled
Sep  9 10:48:00 localhost kernel: [HCIController][RequestPowerStateChange] Calling changePowerStateTo(1)
Sep  9 10:48:00 localhost kernel: [HCIController][setPowerState] 1 (ignore=0)
Sep  9 10:48:00 localhost kernel: [HCIController][setPowerStateWL] 1
Sep  9 10:48:00 localhost kernel: [HCIController][RequestPowerStateChange] changePowerStateTo() returned 0x0
Sep  9 10:48:00 localhost kernel: [HCIController][RequestPowerStateChange] changePowerStateTo(1) returned 0x0
Sep  9 10:48:00 localhost kernel: [HCIController][PerformPowerStateChange] 0->1
Sep  9 10:48:00 localhost kernel: [HCIController][CompletePowerStateChange]
Sep  9 10:48:02 localhost kernel: [HCIController][RequestPowerStateChange] 1->0
Sep  9 10:48:02 localhost kernel: [HCIController][RequestPowerStateChange] sleep is not available
Sep  9 10:48:02 localhost kernel: [HCIController][RequestPowerStateChange] sleep is not enabled
Sep  9 10:48:02 localhost kernel: [HCIController][RequestPowerStateChange] Calling changePowerStateTo(0)
Sep  9 10:48:02 localhost kernel: [HCIController][setPowerState] 0 (ignore=0)
Sep  9 10:48:02 localhost kernel: [HCIController][setPowerStateWL] 0
Sep  9 10:48:02 localhost kernel: [HCIController][PerformPowerStateChange] 1->0
Sep  9 10:48:02 localhost kernel: [AppleUSBHCIController][StopIsochPipeRead] - mInt1IsochInPipe = 0 - numReadsPending = 0
Sep  9 10:48:02 localhost kernel: [HCIController][CompletePowerStateChange]
Sep  9 10:48:02 localhost kernel: [HCIController][RequestPowerStateChange] changePowerStateTo() returned 0x0
Sep  9 10:48:02 localhost kernel: [HCIController][RequestPowerStateChange] changePowerStateTo(0) returned 0x0
Sep  9 10:50:00 localhost CRON[601]: (derekhed) CMD (/Users/derekhed/bin/setiRate > /dev/null 2>&1) 
Sep  9 10:50:00 localhost CRON[602]: (derekhed) CMD (/Users/derekhed/bin/setiProg > /dev/null 2>&1) 
Sep  9 10:51:05 localhost mDNSResponder[227]: mDNSResponder Sleeping at 460276
Sep  9 11:00:21 localhost syslogd: restart
Sep  9 11:00:21 localhost syslogd: kernel boot file is /mach_kernel
Sep  9 11:00:21 localhost kernel: standard timeslicing quantum is 10000 us
Sep  9 11:00:21 localhost kernel: vm_page_bootstrap: 252909 free pages
Sep  9 11:00:21 localhost kernel: mig_table_max_displ = 68
Sep  9 11:00:21 localhost kernel: IOKit Component Version 7.5:
Sep  9 11:00:21 localhost kernel: Thu Aug  5 19:23:49 PDT 2004; root(rcbuilder):RELEASE_PPC/iokit/RELEASE
Sep  9 11:00:21 localhost kernel: 94 prelinked modules
Sep  9 11:00:21 localhost kernel: Copyright (c) 1982, 1986, 1989, 1991, 1993
Sep  9 11:00:21 localhost kernel: The Regents of the University of California. All rights reserved.


[ Reply to This | # ]
Switch to login window upon sleep
Authored by: jgilmorebaldwin on Mar 26, '05 10:51:02AM
Sleepwatcher appears to be at a different location now: SleepWatcher

[ Reply to This | # ]
Switch to login window upon sleep
Authored by: roguelbc on Jul 17, '05 12:52:18PM

They claim that this app can execute a script when the display goes to sleep. I have not found any instuction on how to accomplish this. Does anyone know how to do this?



[ Reply to This | # ]
Tiger installation tips!
Authored by: whit_g on Oct 07, '05 11:21:59AM
I just went through a big rigamarole trying to get this to work in Tiger (including soliciting help from the author of SleepWatcher, who was very helpful) and thought I'd post what I found out. There are really just two alterations to the instructions at the top (my apologies if either of these have already been mentioned): 1. The filename you're looking for (since the 2.0 update) is '/etc/rc.sleep', not '~/.sleep'. 2. The code you need to add to rc.sleep can (or should, I'm not sure) be on two lines, like so:
#/bin/sh

/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession -suspend
This setup is working perfectly on 10.4.2. Hopefully that will help anyone who is still trying to use this tip. I only wish Apple would add this as a system option.

[ Reply to This | # ]
Tiger installation tips!
Authored by: martyl on Oct 10, '05 11:01:46AM

Rather than show the login window, I'm trying to get the equivalent of choosing "Lock screen" from the Keychain menu bar item. Does anyone know how to invoke this from the command line so I can use it with SleepWatcher? Is this as safe as switching to the login screen?

Thanks!

---
Marty Lindower



[ Reply to This | # ]
Tiger installation tips!
Authored by: TicToc on Oct 17, '05 03:20:03AM
Thanks for the tip. It got the hint working on my Powerbook (running 10.4.2). A couple of comments/questions:
1. Shouldn't the first line be
#!/bin/sh
2. Shouldn't there be a
\
after "Menu" in the second line?

3. Implementing this tip does make the login window activate on sleep, for all users. What I liked about the original hint (and the original rc.sleep file) is that it runs ~/.sleep, which can be different for each user. Have you any idea how to get that functionality back? I've tried installing the Sleepwatcher StartUpItem, complete with rc.sleep file, and .sleep as in the original hint, but it fails on sleep with the complaint
System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession: Unable to Fast User Switch: User must be the current console user or root.

Thanks,
John

[ Reply to This | # ]
Tiger installation tips!
Authored by: magnamous on Sep 12, '06 12:45:25AM
In /etc/rc.sleep, change this line:
su - $name -c "$home/.sleep"
to this:
"$home/.sleep"
Worked for me on a Pismo on 10.4.7, but I don't know enough to know whether this is secure or not: it executes as the current user, but I don't know if there are other things that need to be taken into consideration.

[ Reply to This | # ]
Switch to login window upon sleep
Authored by: whit_g on Oct 10, '05 11:43:25AM

Sorry, that reply was intended for the previous poster - I hit the wrong button. :)



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: whit_g on Oct 10, '05 11:41:20AM

I hadn't seen that before. Just FYI, that's identical to the window you get when you turn on the screen saver/sleep lock in the Security panel, but I'm assuming you just want it to appear on sleep, not screen saver activation. I'm afraid I don't know enough about this stuff to say, but I imagine some of the other posters here would.



[ Reply to This | # ]
WARNING: This is broken in 10.4.8...
Authored by: whit_g on Oct 05, '06 10:51:56AM

I discovered to my dismay (because I *love* having this setup) that an Apple code change in 10.4.8 made this tip essentially null and void. If you set it up as described, the code change will now cause your cmd-tab app switcher, cmd-` window switcher and dashboard/expose keys to fail once you put the machine to sleep and wake it up again. I wrote to the SleepWatcher author and he confirmed the problem. Unfortunately, he doesn't have a solution at this time.



[ Reply to This | # ]
WARNING: This is broken in 10.4.8...
Authored by: ptman on Nov 15, '06 08:33:10AM

That is such a shame. Wonder why he hasn't put any info about it on his home page?



[ Reply to This | # ]
WARNING: This is broken in 10.4.8...
Authored by: delight1 on Jun 21, '07 08:05:13PM
try Utility Lock, it looks the screen on sleep, but not on screen saver.
http://semaja2.net/utilitylockinfo


[ Reply to This | # ]
WARNING: This is broken in 10.4.8...
Authored by: steresi on Sep 28, '08 07:15:19PM

UtilityLock is no longer being developed, and the alpha/beta version that's out there gave me problems when waking my laptop from sleep when connected to an external monitor.



[ Reply to This | # ]
10.4.10: works again
Authored by: delight1 on Jun 25, '07 08:43:10PM

as of 10.4.10 (at least), this works again ^_^



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: delight1 on Nov 02, '07 03:21:18PM

the new sleepwatcher (2.0.5)? fixes the ability to script the login window with sleepwatcher



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: gporter6 on Mar 10, '08 12:27:35AM

I don't know if anyone will see this, but i would love to have this little program work on mac os 10.5 with my macbook. does anyone know what i should put as the .sleep script?



[ Reply to This | # ]
Switch to login window upon sleep
Authored by: PizzaCake on Apr 11, '08 03:49:53AM
Use SizzlingKeys, http://www.yellowmug.com/sk4it/ a preference pane mainly for controlling iTunes however has a hot key option to take you to the login window without logging you out. The simply press the power/sleep button. Works on 10.5.2 Intel Alu iMac.

[ Reply to This | # ]
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 http://tinyurl.com/94f3er

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 | # ]
Switch to login window upon sleep
Authored by: bharley on Jan 11, '09 02:03:49AM
changed location of zip file to http://snipurl.com/9sl6q-4792

[ Reply to This | # ]
Switch to login window upon sleep
Authored by: bharley on Jan 20, '09 08:31:52AM

turns out, it is not as secure as i would like (not at all) - when waking up, the .wakeup script immediately changes the require password setting in the system preferences file, and that means that as soon as the screen saver comes on - there is no more need for a password.

oh well. i haven't had a good idea for how to get around this, but if i do - i'll post something.



[ Reply to This | # ]