Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mcmadhatter

macrumors 6502
Original poster
Sep 6, 2005
338
2
Bath, UK
does anyone know of a tool/way of launching an applescript on sleep or wakeup? I have tried sleepwatcher but it rarely works, so I am looking for an alternative
 

gauchogolfer

macrumors 603
Jan 28, 2005
5,551
5
American Riviera
does anyone know of a tool/way of launching an applescript on sleep or wakeup? I have tried sleepwatcher but it rarely works, so I am looking for an alternative

Do you want something that is regularly scheduled, or just each time you wake/sleep? If you are on a schedule, you can use iCal to run Applescripts.
 

mcmadhatter

macrumors 6502
Original poster
Sep 6, 2005
338
2
Bath, UK
Each time I wake or sleep

sleepwatcher executes a script maybe 1 time in 10

basically sleepwatcher is set to execute the scirpt toUpon.wakeup and all the script contains is

#!/bin/sh
osascript /Users/Jeffrey/Library/Scripts/toUpon.scpt
 

mkrishnan

Moderator emeritus
Jan 9, 2004
29,776
15
Grand Rapids, MI, USA
What does console.log say about sleepwatcher on the times when the script fails to execute? Lingon soudns very interesting, but I wonder if the problem that affects sleepwatcher will affect it too.
 

mcmadhatter

macrumors 6502
Original poster
Sep 6, 2005
338
2
Bath, UK
SystemUIServer[1131] Error: Unable to get extended status

I think that is coming from the script, is there a way to put something in in the #!/bin/sh to print something to console.log? then I can check whether it is a problem with a script or sleepwatcher.

Lingon has only has options for doing it at login, I don't think that will fire when the laptop is woken up. I'll have a look now to see what launchd can do.

Here is a list of the options of launchd, i.

StartInterval <integer>
This optional key causes the job to be started every N seconds. If the
system is asleep, the job will be started the next time the computer
wakes up. If multiple intervals transpire before the computer is woken,
those events will be coalesced into one event upon wake from sleep.

is there a way to tell it to stop after a single execution?
 

rothnd

macrumors newbie
Oct 22, 2008
26
4
Help Please!!! Stuck like chuck!!

Hey all

I'm hoping someone out there has learned something useful about launchd, plist's, and timing scripts.

I have a rather simple script that I was trying to make run on a schedule through launchd (15 min to be exact) mainly to get to learn the system.

I'll have to post the code later since I'm currently on a Win comp at work and it won't read the scpt file.

Anyway, the problems... I finally got through it all enough to load the script into launchd through a valid plist ("verified in Lingon" though I don't think was necessary since all Lingon did was add fields withe "false" values). The jist though is the plist file (I've named com.nathan.messagealert.plist to keep the *^#4& formatting going) calls on an Applescript (which runs perfectly fine in the editor or even as an app on startup) which it should then run on a "StartInterval" schedule of 900 sec. Now, I read and found the proper way of making the script an executable file which made it load but it's acting very funny. Remember the time schedule of 15 min I mentioned?? Well, when the script was loaded it kept running and running and running...you get the idea. It wouldn't stop until I killed it.

Any thoughts on why this would react this way? Is a scpt file ok? Does the scpt need a "quit" or "exit" at the end of it? I'm just analyzing the possibilities...

Anyway, I'll post the code when I get home. I'd appreciate anything!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.