Jens Nöckel's Homepage

Computer notes home

Droplet script launcher

Here is a simple way of making shell scripts into clickable applications. There is an even simpler way using Automator, but an application saved that way will display a distracting message "Workflow running..." in the menu bar. The route I'm recording here doesn't have that problem. Another simple method uses an XCode template, see this movie. Unlike that tutorial, my solution also processes files dropped onto the application by passing them to the argument list of the shell script. By separating the launcher's shell script portion from the Applescript (as is done below), you have some added flexibility if you want to modify the shell script without changing the rest of the Application.

In Script Editor, enter the following code (here for xemacs as an example):



To wrap another command, simply replace xemacs by whatever you want. The AppleScript responds to two events:

Save as Application Bundle and add the following shell script to the Scripts Folder in the bundle, under the name launcher.sh:

#!/bin/sh
exec "$@" < /dev/null >/dev/null 2>&1 &
echo $!

This shell script launches a command without waiting for input or output other than the PID.

Make the script launcher.sh executable with chmod 700 launcher.sh

Then save the bundle from Script Editor. The result is a launcher application that can be dragged into the /Applications directory.


noeckel@uoregon.edu
Last modified: Thu Oct 29 15:10:35 PDT 2009