An AppleScript for timers using Quicksilver and Growl

Sep 08, '09 07:30:04AM

Contributed by: fluffy mcduff

QuGrTimer is an AppleScript that combines the power of Quicksilver and Growl to make a wonderful timer application. Take the following code, paste it into Script Editor, and save it as an AppleScript to ~/Library » Application Support » Quicksilver » Actions:

using terms from application "Quicksilver"
  on process text time_
    set sleepTime to 0
    set theText to time_
    set defaults to AppleScript's text item delimiters
    set AppleScript's text item delimiters to " " -- use " " as delimiters
    set theWords to text items of theText
    set timesToRun to (number of theWords) / 2
    set n to 0 -- index
    -- parse time.
    repeat timesToRun times
      set n to n + 1
      set tempTime to item n of theWords as integer
      set n to n + 1
      set tempWord to item n of theWords
      
      if tempWord contains "h" then -- hours
        set sleepTime to sleepTime + tempTime * 3600
      else if tempWord contains "m" then -- minutes
        set sleepTime to sleepTime + tempTime * 60
      else -- seconds
        set sleepTime to sleepTime + tempTime
      end if
    end repeat
    
    set AppleScript's text item delimiters to defaults -- restore default delimiters
    
    delay sleepTime
    
    --begin growl
    tell application "GrowlHelperApp"
      register as application "QuGrTimer" all notifications {"Timer"} default notifications {"Timer"} icon of application "Quicksilver"
      notify with name "Timer" title "Time's up!" description "Your QuGrTimer has finished!" application name "QuGrTimer"
    end tell
  end process text
end using terms from
If the Actions folder doesn't exist, just create it. Relaunch Quicksilver (Command-Control-Q), and open text input mode (launch with hot key of your choice, and press period), then input the desired timer time using the following as acceptable examples:
10 hours 34 minutes 12 seconds 
10 h 34 m 12 s
3 h 5 seconds
3 s 24 minutes
5 h
13 seconds
18 s 4 h
Note that you don't need to enter all fields, and you can even enter them in reverse order. When the timer is done, a Growl notification will appear. You can configure the notification just like any other from the Growl System Preferences panel.

[robg adds: I haven't tested this one.]

Comments (4)


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