You set how often it runs by returning a number of seconds at the end of the handler. "on run" runs once at application launch.
The way a stay-open script works is there's 2 main handlers, the "on run" and the "on idle". Save it as an application and check the "stay open" box to make it stay open after you launch it.
So here's an example applescript for you. What you need is an applescript that stays open all the time and performs its tasks periodically. Run a script whenever an application opens I could not get it to work on Lion, some syntax issues need to be resolved. Lastly, it looks like it may possible to write an Apple Script that does exactly what you want, here is a link to something that may be able to work with some modification. Run the script, you can treat it like any other Application. Name it what you like but be sure to set the file format to "Application" on the "File Format:" dropdown. wait 10 seconds adjust this time to meet your needs Open the AppleScript Editor application.A program like Network Drive Launcher would aid in automatically scripting and connecting to networked shares when you log in.Īlternatively you could write an Apple Script that would replace clicking on the iTunes icon to start iTunes, not ideal since you would have to click the script first. etc/rc.And easy solution would be to automatically have your network shares mounted for you when you log in.
To get this functionality on your computer, just copy the code below into your own /etc/rc.wakeup. All it does is run the short AppleScript command of setting the volume to zero. My personal /etc/rc.wakeup script is shown below. These get run at their respective times, when the laptop is going to sleep or waking up. It loads the launch daemon then creates two files, /etc/rc.sleep and /etc/rc.wakeup. It them moves onto downloading the package and copying the files into the appropriate places. The script begins with deleting any old version of sleepwatcher on the computer. Sudo chmod +x /etc/rc.sleep /etc/rc.wakeup # create script in local user directory and make them executable sudo touch /etc/rc.wakeup # load launch agent sudo launchctl load -w -F /Library/LaunchDaemons/de.
Sudo cp config/de. /Library/LaunchDaemons/de. Sudo cp sleepwatcher.8 /usr/local/share/man/man8 # move files into installation folders sudo cp sleepwatcher /usr/local/sbin # create folders necessary for installation sudo mkdir -p /usr/local/sbin /usr/local/share/man/man8
# download sleepwatcher package, untar, and cd into directory curl -remote-name "" tar xvzf sleepwatcher_2.2.tgz 2>/dev/null Sudo rm -f /usr/local/share/man/man8/sleepwatcher.8 # remove executable and man files sudo rm -f /usr/local/sbin/sleepwatcher # remove plist launchagents sudo rm -f /Library/LaunchDaemons/de. Launchctl unload ~/Library/LaunchAgents/de. 2>/dev/null # unload launch agents sudo launchctl unload /Library/LaunchDaemons/de. 2>/dev/null
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished while true do sudo -n true sleep 60 kill -0 "$$" || exit done 2>/dev/null & #!/bin/bash # acquire sudo at the beginning sudo -v