View Full Version : can I get notification of system becoming idle?


Donald Hall
11-14-2005, 06:34 AM
Does anyone know if there is a way to have a program be notified if the
system enters or leaves an idle state? I am aware of Carbon event loop
idle timers, but they only apply to the current program, not the system
as a whole. I am also aware of the idler.c program that would give me
the actual idle time if I asked for it - not what I want. I want to know
when the idle time exceeding some value triggers an idle state, and also
when it has be reset. (I am not sure if this is what the "busy state"
refers to.)

I have been going over the IOKit documentation, but am finding it very
terse and hard to penetrate.


Thanks for any pointers, tips, or sample code,

Don

--
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
http://www.appsandmore.com
don at appsandmore dot com
"Schedule your scripts with Script Timer"

Sherm Pendley
11-14-2005, 08:59 AM
Donald Hall <spamback[at]127.0.0.1> writes:

> Does anyone know if there is a way to have a program be notified if the
> system enters or leaves an idle state? I am aware of Carbon event loop
> idle timers, but they only apply to the current program, not the system
> as a whole. I am also aware of the idler.c program that would give me
> the actual idle time if I asked for it - not what I want. I want to know
> when the idle time exceeding some value triggers an idle state, and also
> when it has be reset. (I am not sure if this is what the "busy state"
> refers to.)
>
> I have been going over the IOKit documentation, but am finding it very
> terse and hard to penetrate.
>
>
> Thanks for any pointers, tips, or sample code,

You didn't mention if you're using Carbon, Cocoa, or something else. If
you're using Cocoa, you could watch for NSWorkspaceWillSleepNotification
and NSWorkspaceDidWakeNotification.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

Donald Hall
11-15-2005, 06:25 AM
In article <m2d5l3zjtz.fsf[at]Sherm-Pendleys-Computer.local>,
Sherm Pendley <sherm[at]dot-app.org> wrote:

> Donald Hall <spamback[at]127.0.0.1> writes:
>
> > Does anyone know if there is a way to have a program be notified if the
> > system enters or leaves an idle state? I am aware of Carbon event loop
> > idle timers, but they only apply to the current program, not the system
> > as a whole. I am also aware of the idler.c program that would give me
> > the actual idle time if I asked for it - not what I want. I want to know
> > when the idle time exceeding some value triggers an idle state, and also
> > when it has be reset. (I am not sure if this is what the "busy state"
> > refers to.)
> >
> > I have been going over the IOKit documentation, but am finding it very
> > terse and hard to penetrate.
> >
> >
> > Thanks for any pointers, tips, or sample code,
>
> You didn't mention if you're using Carbon, Cocoa, or something else. If
> you're using Cocoa, you could watch for NSWorkspaceWillSleepNotification
> and NSWorkspaceDidWakeNotification.
>
> sherm--

Thanks for the reply, Sherm. I actually have sleep and wake covered -
it's idle that I was trying to do. It doesn't appear that there is any
publicly available way to be notified of the beginning or end of an idle
period. Obviously, there is a way, as something starts the screen saver
after the appropriate period of idleness.

Don

--
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
http://www.appsandmore.com
don at appsandmore dot com
"Schedule your scripts with Script Timer"