Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A script to keep iCal's dock icon current' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to keep iCal's dock icon current
Authored by: jonbauman on Feb 17, '05 10:35:47AM

A couple comments:

  1. It's not necessary to use save this as an application, just save it as a script, and execute it with an osascript command:
    /usr/bin/osascript /path/to/script
    That way it doesn't pop up in the dock, and personally, I think it's faster.
  2. It's not necessary to tell iCal to "activate", which brings it to the front. Giving it a "run" command is sufficient and lets it do it's work in the background (in case you happen to be using the computer when the script runs).
  3. It's probably better to check whether iCal is already running, and only launch & quit it if it wasn't. It would be quite a surprise to be using iCal at midnight and have it quit all of a sudden.

This is the script I use. It has an added check to see whether it has been run yet that day so that if you have a machine that is asleep at midnight and use SleepWatcher or anacron to schedule execution, it won't run unnecessarily.

property last_run : (current date) - 1 * days -- always run the 1st time

if date string of last_run is not equal to date string of (current date) then
	set last_run to current date
	
	if not my isRunning("iCal") then
		tell application "iCal"
			run
			quit
		end tell
	end if
end if

on isRunning(appName)
	tell application "System Events" to return name of processes contains appName
end isRunning

---
jon

[ Reply to This | # ]