idler handler does not work when computer sleeps

Hi All,

I searched this forum and also did a Google search about the above topic but could not find one that satisfactorily addresses the problem that I have.

I have an idler handler that simply fails when the computer goes on Sleep mode. Also, when the screen saver activates, the same thing happens.

I tried the “ignoring application responses” thing but it did not work for me either. Perhaps I put it in the wrong spot but I will check this further.

Meanwhile, if anyone out there has further suggestions in case “ignoring application responses” does not work, I would appreciate your kind help.

Cheers.

archseed :slight_smile:

Hi archseed,

You should post more info.

gl,

Hi Kel,

Many thanks for the quick feedback.

Short of posting the entire codes, here’s what I am trying to do. I wrote a droplet script for automatically zip-compressing documents inside a folder at times interval that can be set by the user to a preferred time.

The timed compression works when the computer is active. Once the computer goes to sleep, the compression fails. I’ve noticed the same thing when screen saver activates.

As it is right now, I can use the automatic backup only by deactivating the screen saver and putting the Sleep option to “Never” in the System Pref pane.

My question is: is there a way to make my stay-open script operate more harmoniously with the computer’s Power options?

I tried to blanket the zip handler inside the “ignoring application responses” block but it still would not work. Right now, I am still fishing for possible work around.

archseed :slight_smile:

You have no doubt noticed that the Energy Saver pane has a “Schedule…” button on which you can schedule a wake-up call to the computer. Now if we only knew how that worked… where that info was stored and how it remained active while the machine slept. I don’t, but I’m interested.

Hi archseed,

Scirpts are suspended when the computer sleeps, so set sleep to never is a must. It’s strange that the screensaver affects the script though. Something in your script must need something to be displayed?

Thanks Adam,

I’ve searched long and hard for any possible item in AppleScript that would let me fix my problem but to no avail.

Yes, it would be nice if someone could figure out how to make the sleeping computer wake up. There is an option for the computer to wake up on Ethernet Admin’s network call but it is hardly what I want. I wonder why Apple Inc. has not provided this option.

I’ll keep searching and let everyone know if I chance into a possible solution…sigh :frowning:

archseed

Hi Kel,

Yes, a dialog box simply alerting users that the zip compression was successful…and things like that.

I’ll go and look into it but still the Sleep thing is the one that makes me scratch my head. I wonder where we can dig the info that Adam just referred to in his post? Any takers out there?

archseed

Think I found somthing with the screensaver affecting the script.

Instead of making it an idela handler you could make it a cron or launchd job.

If you’re using panther you have to use cron which won’t wake from sleep, but i found a cronwake daemon which will wake the computer when designated cron jobs are scheduled to run.

On Tiger you have either option, though the daemon hasn’t been tested under 10.4. Launchd won’t wake from sleep either, but unlike cron if it misses a job it runs that job as soon as it can… ie when you wake the computer from sleep yourself.

There wasn’t anything with the screensaverengine, but if you want to wake up the display sleep, you can simulate the keystroke:


tell application "ScreenSaverEngine" to activate
delay 3
tell application "System Events" to keystroke space
display dialog "I'm up."

This was done in Scirpt Editor, so modify script for ‘display dialog’.

I’ve never seen a way to wake up from computer sleep in OSX. They used to have preOSX.

I just read Adams post about they added that in Tiger. Good luck in finding a way. Maybe you can ui script System Preferences and reschedule the wake up.

gl,

But the real gist of my message, Kel, was how does the Energy Saver do it. I agree that you could schedule a wakeup, then reprogram for the next one, etc., but I’d love to know how the system “knows” when to wake up per that setting if it’s sleeping. Is it secretly waking up the cpu periodically to check the time? Using what engine? Storing the info where? Can we get at it?

Don’t know that this is even relevant, and have to wait a few minutes to test…

do shell script “sudo pmset schedule wake "02/12/07 11:30:00"” password “password” with administrator privileges

… will generate a file: /Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist

pmset repeat can do more than a one time event.

Peter B.


The script above had the desired effect… and though I’m no good with shell scripting, it looks as though it might be modified to work for your needs… provided you can feed it an appropriate time to wake… before sleep.

Am I way off the mark of this thread?

Peter B.


nice find Peter!

Indeed, nice find - the whole enchilada, in fact. :slight_smile:

I note, however that /Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist contains a WARNING: "Do not edit this file by hand - it must remain in sorted-by-date order, which means Use pmset to do what you want; don’t edit the file.

Hi Guys,

I missed all the lively exchanges here. Gosh! It’s hard to live without the Internet nowadays.

Anyway, thanks for all your efforts. While gone from the thread, I did try the UI element scripting…later on suggested by Kel. Though it works to wake up the computer, I must warn that it is not very reliable. Sometimes, it works and sometimes, it doesn’t. Another problem is that if it begins to work, it will stop working after 2-3 times that the UI handler is called. I don’t know why. Is there a built-in limit on calling UI handlers? I doubt it but wonder why it behaves like so.

I also tried the “click” method instead of keystroke and it also works…the difference is that the computer stays on sleep mode but the script works…but then again, the 2-3 limit on subroutine calls persist. I have checked my program but it does not appear to have anything that might cause the limit to be set.

Any thoughts on this limit? I was so darn excited I thought my problem was solved but obviously, it was a premature exhiliration.

Now, I am off to checking other suggestions in this thread.

Thanks again.

archseed

That sounds like the zipping process for some files must take quite a while and the computer sleeps again because there is no desktop action. Some time ago, I had my machine wake up as per Energy Saver schedule at 3AM and then immediately started Jiggler, an app that advertises: “No-doz for your Mac”. All it does is run the cursor around in a little circle ending where it started on a settable interval shorter than your sleep time. With that running, I did my backup task, quit Jiggler and went back to sleep.

Hi All,

OK, I’ve run out of maneuvering room with the UI handler to (click or keystroke space) to wake up a sleeping computer.

The UI handler works but only for a limited time…up to 2-3 times and then no more. I’ve checked carefully, it’s not the zipping process that’s creating the problem. Even for small files, when the time interval I pass on to the idler is long and the computer sleeps, the script just would not work.

Now, I would like to try the do shell “sudo pmset schedule wake” suggesed by Peter Bunn but would like to be able to pass a variable instead of a string literal for date and time. That way, I could set the wake schedule according to the user-defined time interval.

Is there a way to pass a variable parameter instead of the string literal?

Thanks a lot. Any help is much appreciated.

BTW, I searched the AppleScript forum for any lead on the issue but I could not find one. That’s why I decided to post the question.

archseed :frowning:

I hesitate to offer this as my experience with shell scripts is very limited…

Also, I have no idea (at present) how to simply set the wakeup to ‘5 hours from now’ but there are plenty of date/time coercion routines archived on this forum, and man pmset should give you some more ideas how to set this up properly.


try
	
	set time_to_wake to text returned of (display dialog "Schedule Wakeup..." & return & return & "In strict  - MM/DD/YY HH:MM:SS - form." & return default answer "01/01/07 12:00:00" buttons {"Cancel", "OK"} default button 2)
	
	do shell script "sudo pmset schedule wake " & quoted form of time_to_wake password "password" with administrator privileges
	
on error
	
	display dialog "Improper Date or Date Format..." & return & return & "Try again?" buttons {"Cancel", "Try Again..."} default button 2
	
	if button returned of the result is "Try Again..." then
		
		try
			
			set time_to_wake to text returned of (display dialog "Schedule Wakeup..." & return & return & "In strict  - MM/DD/YY HH:MM:SS - form." & return default answer "01/01/07 12:00:00" buttons {"Cancel", "OK"} default button 2)
			
			do shell script "sudo pmset schedule wake " & quoted form of time_to_wake password "password" with administrator privileges
			
		end try
	end if
end try

The default time entry will reliably throw an error on my machine. A time in advance of the current time seems to work… or at least generate or modify the ‘com.apple.AutoWake.plist’ file… but the result has not actually been tested.

Have Fun.

Peter B.


Incidentally, I might add that ‘casually’ scheduling wake events may not be a great idea for notebook users. I don’t know whether a notebook will wake with lid closed on schedule or not, but it ain’t a good idea, as overheating could result.

Peter B.