View Full Version : A Sleepwatcher question

02-19-2008, 03:23 PM

I'm hoping someone out there on these forums will be able to help me with my situation.
Before I start, I want to say that I have done extensive searches on both the Internet at large and one these forums for an answer to my question, and have not found anything definitive. So I apologize in advance if this was in fact answered somewhere and I missed it.
Also, my Unix skills are basic. I've not written scripts or used complex commands. I'm fairly comfortable running commands if I know what I'm doing, or I'm told the commands to run.

My situation:
I'm trying to use the Sleepwatcher daemon by Bernhard Baehr to execute what i think should be a pretty simple command. Basically, I manage a number of Macs at my job, and I want to use Sleepwatcher to switch out to the login screen (FUS is enabled) after a set period of inactivity by the user.

I'm trying to use the Sleepwatcher daemon, because the built-in Mac OS X mechanisms do not work for my purpose.
The option in the Security prefpane to log out after x minutes of inactivity actually logs the user out of their account, closing windows and applications, which is undesirable.
The screensaver password protection is also inadequate because these are non-admin users, and if User A walks away, and User B wants to log into their own account on the machine (either local or via a Directory service), they would first need User A's password to unlock the Mac, which is a security risk in itself.

Therefore, sleepwatcher seems like the best bet to implement this. I know the command to switch to the log in window:

System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

This was easily found on the 'net. I have edited both scripts (not sure which one does what I'm looking for) that are installed by Sleepwatcher, /etc/rc.sleep and /etc/rc.wake to include this command. The scripts are executable, and I can invoke the scripts manually and they work as I want.
I can even set it up so that when the Mac goes to sleep, the script goes into action and switches to the login window. Unfortauntely, this is where it breaks down. If I set the Mac to sleep after, say, 30 minutes, it switches out to the login window and then promptly puts the Mac to sleep. This is not what I want. The issue for me here is that I also remotely manage these Macs using ARD and a VPN connection. ARD over a VPN connection has proven flaky in waking a sleeping Mac. Works fine on the local LAN, but only occasionally over VPN. If all the Macs I manage go to sleep on me, I will have a hard time managing them after hours.

So the issue is, how do I get the idle time set in Sleepwatcher? I looked at the man page for it and I know the flag -t sets the idle time. The -i flag is what I'm not sure about. It says it works in conjunction with the -t flag and runs the script, but am I supposed to enter the script after the flag, or am I just referencing it somewhere? Also, do I edit the /Library/StartupItems/Sleepwatcher/Sleepwatcher daemon with something? I've seen some examples on MacOSXHints that seem to indicate editing that will work. I've tried that and can't seem to get it to invoke after the period of idle time I set.

So… I'm a bit stuck and I'm obviously not doing something right.

i contacted the author about this, but have not heard from him yet.

So, does anyone have a clue about how I can get this to work? I feel as though I've exhausted all my options. I hope someone can help me. I really would love to get this to work.

Thanks in advance

02-29-2008, 12:55 AM
Have a look at this thread, it sounds pretty close to what you're looking for.