Created
May 12, 2009 03:25
-
-
Save wfarr/110284 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- register Things for growl notices | |
| tell application "GrowlHelperApp" to register as application "Things" all notifications {"ToDo Notice"} default notifications {"ToDo Notice"} | |
| tell application "Things" | |
| -- get items in the today list | |
| repeat with todo in to dos of list "Today" | |
| -- growl only open itesm | |
| if status of todo is open then | |
| if notes of todo is not missing value then | |
| -- get the notes | |
| set todoNote to notes of todo | |
| -- clean it up | |
| set msgLen to the length of todoNote | |
| if msgLen > 80 then | |
| set noteLim to msgLen - 7 | |
| set msgText to get texts 28 through noteLim of todoNote | |
| set msgText to msgText & " " & "..." | |
| else | |
| set noteLim to msgLen - 7 | |
| set msgText to get texts 28 through noteLim of todoNote | |
| end if | |
| -- Strip double carriage returns to make things fit nice | |
| set msgText to my findReplace(msgText, return & return, return) | |
| else | |
| set msgText to " " | |
| end if | |
| my growlIt(name of todo, msgText, true) | |
| end if | |
| end repeat | |
| end tell | |
| -- the growl handler | |
| to growlIt(aTitle, aNote, hold) | |
| tell application "GrowlHelperApp" to notify with name "ToDo Notice" title aTitle description return & aNote application name "Things" icon of application "Things" sticky hold | |
| end growlIt | |
| -- Simple find and replace routine | |
| on findReplace(the_string, search_string, replace_string) | |
| tell (a reference to my text item delimiters) | |
| set {old_tid, contents} to {contents, search_string} | |
| set {the_string, contents} to {the_string's text items, replace_string} | |
| set {the_string, contents} to {the_string as Unicode text, old_tid} | |
| end tell | |
| return the_string | |
| end findReplace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment