An AppleScript front end to 'calendar'

Apr 05, '02 12:14:23AM

Contributed by: Harold

Now that we have all these cool Unix utilities I decided to unleash some AppleScript upon them. The following script will display the output of the calendar command in a dialog, allowing you to then place the contents on the clipboard. Paste the following into script editor, modify to your liking and compile:

set n to do shell script "calendar -f ~/Library/calendar"

display dialog "Calender:\r" & n buttons {"Clipboard", "OK"}¬
default button 2
if the button returned of the result is "Clipboard" then
set the clipboard to n
display dialog "The calendar is on the clipboard." buttons¬
{"Cool"} giving up after 10 default button 1
-- the "giving up after 10 " part basically assumes it's cool
-- after 10 seconds of inactivity and removes the dialog
end if
Some notes to help make this easier to use:
  1. Create the calendar file first with touch ~/Library/calendar, and then edit it to add your entries.
  2. Read the man pages for calendar (man calendar) for information on how to format your calendar file.
  3. There are some sample calendars in /usr/share/calendar; to see the script in action, try using /usr/share/calendar/calendar.computer (or any of the others in that directory) in the first line after the "-f". You can also add extra options (-l 30 to show the next 30 days, for example).
Save the script in compiled mode, and then just double-click any time you'd like to access the calendar file.

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20020405001423457