Visual Feedback from Apple Scripts

I am probably overly abusing Better Touch Tool. As an example, while reading a book in Full Screen mode with Skim, I want to create different types of annotations but I do not want to use the menu or even the keyboard to switch annotation types. I want to keep my hand on the trackpad and do what’s needed – including saving. The issue I saw is that when using gestures, I’m not quite sure whether they actually were executed. Adding today the “save” operation, I definitely needed a simple way to display a notification on whether the given action has been performed. Enter Growl. And a very simple Apple Script that displays, using Growl, what ever has been passed on the command line. The script is given below; here’s how it works.

First of all, we save the script into some location. For me, it is /pgm/scripts, but you can place it anywhere you want. Next, I want to have a setup similar to this in Better Touch Tool:



Notice those arrows beneath each primary action? So for example, a “TipTap Left”, in Skim, first of all executes “Command-1”, which is equivalent to choosing the “Text selection” mode through which I can select text to copy to the clipboard. Once I’ve defined that action, I click on the “Attach Additional Action” button, then start entering “exe” into the search field and click on the only option that remains:


This gives me the option to enter a command; it is also possible to just call any Apple Script through another execution option; yet that does not allow to pass command line parameters. That’s why I chose to run the Apple  Script from the command line:



The command line entered uses a parameter to pass any notification that you want to display. Once saved, what happens when running the gesture is that it first does whatever actual hotkey I had selected as primary action, and then shows the notification:



  Very very simple script to show a message.
  For notifications, Growl is required.

on run argv
	set msg to my joinList(argv, " ")
	tell application "System Events"
		set isGrowlRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
	end tell
	if isGrowlRunning then
		tell application id "com.Growl.GrowlHelperApp"
			-- Make a list of all the notification types 
			-- that this script will ever send:
			set the allNotificationsList to ¬
			-- Make a list of the notifications 
			-- that will be enabled by default.      
			-- Those not enabled by default can be enabled later 
			-- in the 'Applications' tab of the growl prefpane.
			set the enabledNotificationsList to ¬
			-- Register our script with growl.
			register as application ¬
				"Notifier" all notifications allNotificationsList ¬
				default notifications enabledNotificationsList ¬
				icon of application "Script Editor"
		end tell
	end if
	if isGrowlRunning then
		tell application id "com.Growl.GrowlHelperApp"
			notify with name ¬
				"Notification" title ¬
				"Notification" description ¬
				msg application name "Notifier"
		end tell
	end if
end run

to joinList(aList, delimiter)
	set retVal to ""
	set prevDelimiter to AppleScript's text item delimiters
	set AppleScript's text item delimiters to delimiter
	set retVal to aList as string
	set AppleScript's text item delimiters to prevDelimiter
	return retVal
end joinList