Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to run a apple-script on Mac OS X on startup. The script shall run during the complete lifetime of the user session.

What is the best solution to do this?

My Script:

on idle
    do shell script "/usr/local/bin/wol -p 9 0:1d:63:19:b7:32"
    delay 120
end idle

Any help will be very appreciated.

share|improve this question

4 Answers 4

up vote 6 down vote accepted

When saving the script in the script editor, save as an application bundle, then add it to the startup items in login system preferences:

alt text

If you want it to run in the background, you can use iBackground Scripts, a free tool to make applescripts run in the background.

alt text

share|improve this answer
    
Thanks for your response. I've already done that. The problem is, that the apple script will be display in the dock during the complete user session. Is there any way to get rid of the apple script symbol in the dock? –  road242 Jan 23 '10 at 19:46
1  
Just added that info :) –  John T Jan 23 '10 at 19:47
    
Thanks again. Works fine and runs in background. But I'm asked if I want to run the script on startup. Is there a way to avoid the question dialog? –  road242 Jan 23 '10 at 20:11
    
Hmm. Maybe another applescript to tell it "yes" would do? –  John T Jan 23 '10 at 20:14

I know your question is about running an Apple Script, but if all the script is doing is running /usr/local/bin/wol every 2 minutes, a simpler solution might be to use a launch daemon?

Either in /Library/LaunchDaemons if it's to run continuously even without a user logged in, or in ~/Library/LaunchDaemons to run per user (bearing in mind there could be more than one instance running if you've got more than one user logged in).

At least you don't have to worry about popup windows getting in the way.

share|improve this answer

As an alternative to the AppleScript way, I typically use launchd for handling things like this. launchd is customizable and very powerful.

http://developer.apple.com/MacOsX/launchd.html

share|improve this answer

To prevent the 'do you want to run...' dialog: As you're saving your script as an application bundle, untick the 'Startup Screen' checkbox in the Save As dialog.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.