Idle?

Hey guys is there any way to make a applescript run a cmd when the machine is idle, not the applescripts on idle but i mean like how a screen saver kicks in when its idle.

You might use the screen saver’s timing to do it. When the screen saver is running, there exists a process called “ScreenSaverEngine” which isn’t there when it’s not. An on idle script that ran an if exists process “ScreenSaverEngine” then do my thing test cycled periodically might work for you.

The other way is to get the “AppStartSaver” screen saver which will start any application when the screen saver starts.

The AppStartSaver Read Me says (in part):

Is there any other ways then using the screensaver option you posted, some users didnt want that way so yeh.

What do you want to do exactly? Run an applescript after a defined number of seconds that the the machine is idle? If so, you can run a script at a regular interval that starts with:

set idleTime to (do shell script "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle,\"\";last}'") as number
if idleTime > 30 then
	beep 5
end if

There are some issues when the computer wakes up from sleep. If the script above is what you were looking for, I’ll be happy to tell you some more