Skip to content

Instantly share code, notes, and snippets.

@kanghyojun
Created November 7, 2011 01:12
Show Gist options
  • Save kanghyojun/1343954 to your computer and use it in GitHub Desktop.
Save kanghyojun/1343954 to your computer and use it in GitHub Desktop.
-- GrowlIt 1.2
-- Description:
-- An applescript that displays events and to-do's from iCal as Growl notifications.
-- Based on multiple other Applescripts found in multiple sites.
-- No warranty. Tested with iCal 4.0.1 and Growl 1.2 under Mac OS X Snow Leopard 10.6.2
-- Written by Leonardo Alcantara software@imagn.net
-- Last modified: 2010-03-28
---------------------------------------------------------------------------------------------------------------------------------
set myAllNotesList to {"Events"}
set appName to "GrowlIt"
set now to current date
set theEventSummary to ""
set theEventDescription to ""
set interVH to 0
set interVM to 0
set startD to now - 1 * hours
set endD to now + 1 * days
set TFlex to 1
tell application "GrowlHelperApp" to ¬
register as application appName all notifications myAllNotesList default notifications myAllNotesList icon of application "iCal"
tell application "iCal"
repeat with thisCalendar in calendars
repeat with thisEvent in ((every event of thisCalendar) whose ((start date ≥ startD and start date ≤ endD) or (end date ≥ now and start date ≤ startD)))
if exists open file alarm of thisEvent then
set interV to -1 * (trigger interval of first open file alarm of thisEvent)
if interV > 59 then
set interVH to interV div 60 as integer
set interVM to interV - (interVH * 60) as integer
end if
if (start date of thisEvent is greater than (now + (interV * minutes) - (TFlex * minutes)) and start date of thisEvent is less than (now + (interV * minutes) + (TFlex * minutes))) then
tell thisEvent
if interVH = 0 then
if exists summary of thisEvent then
set theEventSummary to (summary & " in " & (interV) & " minutes")
end if
else
if interVH = 1 then
if exists summary of thisEvent then
set theEventSummary to (summary & " in " & (interVH) & " hour and " & interVM & " minutes")
end if
else
if exists summary of thisEvent then
set theEventSummary to (summary & " in " & (interVH) & " hours and " & interVM & " minutes")
end if
end if
end if
if exists description of thisEvent then
set theEventDescription to description
end if
end tell
tell application "GrowlHelperApp" to ¬
notify with name "Events" title theEventSummary description theEventDescription application name appName with sticky
end if
end if
end repeat
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment