Droplet Maker is a BBEdit package for making simple droplets/applets from a shell script. Anything with valid a shebang. Perl, Python, Ruby, PHP etc.
So it turns a target script named Make Report.py into Make Report.app.
My definition of applet is an app that performs a simple ‘script’ like action when double clicked. Usually taking a file or files as input.
A droplet takes a file or files as input when they are dropped on it’s icon.
Though there are other, better solutions; Automator.app, Shortcuts.app, or Platypus.app, I wanted to easily use source-control along with other workflow nicesties & features I’ve become accustomed to in BBEdit.
Copy & pasting a script into an Automator action really sucks after a while.
I tried to make this a little more robust then the finicky little package that I’ve been using for a while. I’m sure that there are a thousand edge cases that I haven’t thought of. Give it a try but keep in mind this is not a professional solution.
-
Clone this repository to a safe place.
-
Run
rake install
from the command line while in the repository directory.
rake install This installs this project as a BBEdit package in ~/Library/Application Support/BBEdit/Packages/ as Droplet Maker.bbpackage.
rake uninstall Removes the package.
rake test:cleanup Removes the build/ directory & the file droplet_script.applescript from the projects test/ directory.
This package only works with a BBEdit project. The project must have a root directory. More specifically the directory that houses your target script (a.k.a. Make Report.py) must be the first item in the project.
BBEdit “insta” projects -which are made by dropping a project’s directory on the BBEdit icon- are also supported.
This package consists of two commands, Setup & Build.
You are meant to run Setup once & Build after you make changes.
Setup makes a build/ directory & a file named droplet_script.applescript.
The build/ directory is the where your applet is saved when you run Build.
The droplet_script.applescript defines the input of the final applet or droplet. I tried to define some helpful and sane defaults but you likely want to edit this file.
By default droplet_script.applescript is setup to act as a droplet & applet which ask for file(s) after being launched.
-
on run
Commands in this handler run when you double click the applet. By default it asks for files via a dialog box & runs the target script with the file paths as parameters.If you want to define a different kind of input, such as a user provided string, that would likely happen in this handler.
-
on open
This is what happens when a file is dropped on the droplet icon. It’s default setup works just likeon run
, except the files are passed in through thedrop\_files
parameter.Either
on run
oron open
must be present. Both are available by default, allowing the script to be an applet & droplet. -
on run_shell_script
This handler is called from bothon run
&on open
. It calls your target script. It takes a string as a space separated parameter list. It then passes this string to your target script as if it’s a shell command (it’s in fact calling an executable copy of your script from inside the app bundle).It is required.
-
on format_params
This is a “helper” called by bothon run
&on open
. It takes a list of AppleScript file objects & returns a string containing the files paths. It also included a path to the applets enclosing directory by calling theon path_to_app
handler.You can easily edit
on format_params
to make that optional. -
on path_to_app
This handler takes a sting, & appends the path to the applets parent directory. So it takes the parameters defined earlier for the target script & adds the path back to the applet to the end of the string.
Run the build command while your target script is selected. If it is not selected you will get an error. It will create a an app bundle with the same name as the selected target file but with the .app extension in build/.
It is actually using droplet_script.applescript as a parameter for osacompile
to make the app bundle in the build/ directory. Your target script is made into an executable & copied into the app bundle. You can find it & it’s AppleScript companion in /Project Folder/build/Project.app/Contents/Resources/Scripts/.
-
main.scpt is is the “compiled” version of droplet_script.applescript.
-
shell_script is an executable copy of your target script.
Build will also look for a image called icon.png in your project directory. It will use this image, which should be 1024 by 1024 pixels, to make a custom icon for your applet or droplet.
Icon.png is not required. MacOS will provide a default icon.
If you want to make changes to your copy of Droplet Maker, I suggest making a BBEdit project file for it.
Droplet Maker will check if it is being called from a project called Droplet Maker. If this is the case it will use this directory as the project root directory. Setup & Build will run from here.
It includes a test icon icon.png, a target script Test Me.rb & text file to test if an incorrect file is selected no_shebang.txt.
These files represent something pretty close to minimum requirements for Droplet Maker to work.
This is most useful if you are making changes to the package. It is also a good way to give Droplet Maker a dry run.
I used Droplet Maker for this little Finder button app. It may be helpful as a simple example.