Appify: Wrapping Shell Scripts as Applications in Mac OS X 10.6

Annika Backstrom
in misc, on 23 September 2010. It is tagged #Computers, #code, #console, #scripting, #shell, and #tips.

Today I'm publishing appify, a shell script that turns any other non-interactive shell script into a double-clickable Mac OS X application bundle. The only magic: Mac OS X will not execute the script if it's smaller than 28 bytes, so appify will balk if your script needs padding.

The Background

For several years now, I have used a series of AppleScripts to automate enabling and disabling of the Mac OS X screen saver password. The scripts were pulled from a thread on the MacWorld forums and have worked well, save for one detail: there is quite a lot of overhead in launching a compiled AppleScript just to execute two commands in the shell:

do shell script "defaults -currentHost write askForPassword -int 0"
do shell script "/Users/annika/bin/notif"

Under heavy load (ie. with all my normal apps, plus VMware Fusion running one or more virtual machines) I often wait 30 seconds or more to enable or disable the password.

Steam was recently ported to Mac OS X, and it has the ability to create application shortcuts on your Desktop. Digging into one of these applications, you see the following hierarchy:

annika@fsck[0]:/Applications:0$ find "Team Fortress"
Team Fortress
Team Fortress
Team Fortress
Team Fortress
Team Fortress
Team Fortress
Team Fortress

Here's Info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

And the good stuff,

# autogenerated file - do not edit

open steam://run/440

This was a pretty big "wow" moment for me. No AppleScript, no .command files (which launch, just pure, instant command line gratification. appify was born to quickly convert shell scripts into applications.