Call shell script after delay with Applescript

Sharing and discussing custom actions for LaunchBar
Post Reply
nemozob
Posts: 5
Joined: Fri Jun 15, 2012 8:14 pm

Call shell script after delay with Applescript

Post by nemozob » Wed Sep 26, 2012 5:45 am

In the code below I'd like the 'do shell script' line to fire after the delay. I realize this doesn't compile. Does LaunchBar have a way of calling a shell script like this?

Code: Select all

on handle_string(msg)
   
   set duration to last word of msg
   set mLength to (count characters of msg)
   set dLength to ((count characters of duration) + 1)
   set reminder to (characters 1 thru (mLength - dLength) of msg) as string
   
   tell application "LaunchBar"
             do shell script "/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -title 'Timer' -message '" & reminder & "'" after delay duration
             delay
   end tell
   
end handle_string


Original code is from http://hypertext.net/2010/02/launchbar-timer

iRounak
Rank 4
Rank 4
Posts: 191
Joined: Fri Oct 23, 2009 7:11 pm
Contact:

Re: Call shell script after delay with Applescript

Post by iRounak » Sun Jan 20, 2013 7:33 am

Code: Select all

on handle_string(msg)
   
   set duration to last word of msg
   set mLength to (count characters of msg)
   set dLength to ((count characters of duration) + 1)
   set reminder to (characters 1 thru (mLength - dLength) of msg) as string
   
   tell application "LaunchBar"
             delay 5    --delay the execution of next statement by 5 seconds
             do shell script "/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -title 'Timer' -message '" & reminder & "'"
   end tell
   
end handle_string

Post Reply