Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: detect sleep



Calling a function of any sort every few milliseconds just to see if it was called "on-time" will waste CPU cycles... just the sort of thing that would get your widget deleted from my Mac, and would potentially frustrate the average user.

What if EVERY widget did this?

All of a sudden the Mac becomes a lot more windows like with faceless things running in the background taking up CPU cycles with no clear indication what it is. In this situation "DashboardClient" becomes only slightly better than "run.dll" or "svchost.exe"...

If the interval was a little larger (say 30 seconds) and you observe that it's been more than 31 seconds, then perhaps you could assume the user had slept and reawakened the computer in that time window.

Perhaps an even more reasonable approach would be to have your widget tail the system log to look for the most recent wake event:

tail /var/log/system.log | grep 'System Wake'


returns something like this:

Jul 1 08:44:10 errol kernel[0]: System Wake


However, this approach would require admin privileges...

Can you give a little more information about why you need to know if the computer is going to sleep or waking up?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/email@hidden


This email sent to email@hidden
References: 
 >Re: detect sleep (From: Michael Kwasnicki <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.