Dec 23, '07 10:30:01AM • Contributed by: Anonymous
After installing Leopard, my iMac would no longer auto sleep. It worked flawlessly in Tiger. I searched google and found many others having similar problems. I found many different fixes, such as removing the PowerManagement plist file, unplugging all devices, and not running certain widgets or programs. However, no matter what I did, it would not auto sleep. It would stay asleep if I manually put it to sleep.
I called Apple and was on the phone with them for about two hours before they said it is probably a hardware problem, thanks for calling. After all that hassle, I decided to see if AppleScript could put it to sleep, and it did. Once I found that out, I just wrote a python program that keeps track of how long the screen saver is running. Using that, it determines if the system has been unused for the period the user set in system preferences for machine sleep. I put this in cron to run once a minute and it has been working very reliably. Note: I didn't make it robust enough to find the screensaver preferences file. I hard-coded it to mine, so if anyone wants to try it, you would need to update the numbers at the end of the saverFile value.
[robg adds: I haven't tested this one.]
