On wake-up from sleep...

How do I run a program/command upon wake-up from Sleep? Is this possible?

See this page…

http://ibeezz.reboute.net/en/

Though not as cool as iBeeZz (which I think means “I be sleeping,” right?) and lacking the ability to run scripts or other events on wake (which is what the original question was about and Greg answered quite nicely), if you just want a utility for scheduling sleeping and waking, take a look at the freeware app ResurrXtion.

Jon

Thanks for the suggestion Mr. Spence. Ibeez is exactly what I’m looking for. What I want to do is check for mail on wake up from sleep and this program does exactly that. Although not an applescript question, per se, other than I want to launch applescripts upon awakening from sleep, I appreciate your reply.

And thanks to you to Jonn8. I’m always open to other suggestions.

Upon really looking at iBeeZz, I’m ashamed to say it’s not quite what I want. I’m not looking to schedule a wake-up time from sleep and then run a script. I’m looking to run a script whenever I wake-up from a sleep on a daily, uncheduled basis. This means that no matter when I wake up from sleep I want to run a script. Which is numerous times per day. I hope this helps.

If that’s all you want to do, why not just create a rule in your mail app to constantly check for new mail? I have one that checks every 5 minutes and it runs as soon as it wakes from sleep. No scripting necessary.

Jon

How do you get it to run when you awaken from sleep? For me I have to wait till whatever time I have set for mail to ‘get mail’ expires. eg 5, 10, 15 minutes.

Hi,

I’ve been running this scirpt and it seems to work ok:

global target_date

on run
set target_date to (current date) + 60 – 1 minute
end run

on idle
set cur_date to (current date)
if cur_date > target_date then
say “Good morning.”
– your stuff here
end if
set target_date to cur_date + 60
return 1
end idle

If you don’t know about idle handlers, just say. It says good morning after awakening if it’s been asleep for more than 1 minute.

gl,

How do I make this script work? Can you give me a step by step summary of how you make it work?

Hi Denns,

Paste or type the script into the Script Editor, hit the check syntax button, Save As Application - stay open, never show startup screen. Then you just run the scrip t application.

gl,

Kei,
Thanks for the reply. The key for it to work for me was ‘always stay open’. It now works perfectly. Thanks again.

You might also want to check out the little command line app/daemon Sleepwatcher (http://www.bernhard-baehr.de/) which you can set to run any command line or applescript right before the computer goes to sleep or right after it wakes up. Pretty handy.

To run an applescript on wake up you’d do something like:

/usr/local/sbin/sleepwatcher -w ~/wake

and in ~/wake you’d put

open ~/mywakescript.scpt


return is important at end of script!

Sorry to bring this up again, but can you explain this more clearly?

The first item on the agenda is to download SleepWatcher and install it. It’s a shell script, described as follows in its readme:

How do you do that? I opened them in TextEdit and it looks like Greek to me.

I haven’t installed it, so don’t know what they look like. They are shell scripts, however. They can be modified in TextEdit (rather than BBEdit or TextWrangler, say) only if you save them as text. If you’re not familiar with the command line, changing permissions, etc. don’t even try - (that’s why I never have, although I’d like to use this).

I gather from the thread that you put a file called “wake” in a special place that was a unix executable with one command - to start your script. Sorry I can’t help.

Those who prefer an AS-only solution may consider the following:

Make a stayopen applet that checks its last calling every 3 minutes or so:


global td
set  td to current date

on idle
if td - current date > 220 then WokeFromSleep()
set td to current date
return 200
end idle

on WokeFromSleep()
--your routinues
end WokeFromSleep


For me this appears not 100% reliable, but comes close.
Improvements welcome.