On Aug 7, 2009, at 4:33 PM, Ryan Schmidt wrote:

On Aug 7, 2009, at 13:43, Scott Haneda wrote:

Before I jump over to the launchd mailing list, I wanted to see if anyone knew a way to detect a Mac going into sleep mode or waking from sleep mode.

[snip]

I'm aware of sleepwatcher, which seems to work semi ubreliably, so I am looking for an alternative.

Oh. This is the first I've heard of it being unreliable. What have you observed?


First, it was just reading the comments on Version Tracker, which I sort of take with a gain of salt anyway, but it got me in the mind to at least pay attention.

I made a very simply test case, which was to install, and I am using the Startup Item with it, but I also have tested with ./sleepwatcher - d as well. I put in ~/.sleep and ~/.wakeup. In each of those files, I have very basic code:

#!/bin/bash
date=`date`
echo "$date Clearing out ssh-agent because we are sleeping" >> ~/ Library/Logs/sleepwatcher.log;
launchctl stop org.openbsd.ssh-agent

While the launchd may error, and cause issues, I do not think that is the case, the basic echo line should not cause any issues. My .wakeup is identical other than I change "...sleeping" to "...waking"

I performed 10 total sleep and wake cycles, I ended up with only 18 lines total. So 8 sleep and 8 wake log lines were made. I believe it is reliable in that if it works, it will work both on the sleep and wake side of the equation. My experience shows a balance in the log lines, half are wake, half are sleep.

My only guess is that if you sleep/wake too soon, there may be some confusion, perhaps the sleep did not fully enact, though that is just a guess.

I will look into, and do my best to solve this, though first, I need to solve the ssh-agent issues, or I will not even need to use this application. I think the first thing I will do when I get ssh-agent playing nice, is to convert the startup item to a launchd item.
--
Scott * If you contact me off list replace talklists@ with scott@ *

_______________________________________________
macports-dev mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev

Reply via email to