Passing command-line options to OS X Apps with Platypus

Platypus from Sveinbjorn Thordarson

I love the Google Chrome Canary browser. For the last year, it has been my browser of choice on Mac, Windows and Linux after leaving the chaos and mess that has become Mozilla Firefox.

The only aspect that is bothersome for me in Chrome or Chrome Canary is the way the software deals with self-signed SSL certificates. I use a lot of them internally. Because of the current inability to trust self-signed certs in Chrome, you are forced to click through an error/acknowledgement warning prior to continuing to the address you want. This can get really annoying after a few times a day per site across a bunch of internal sites I use for monitoring or various sysadmin functions. Clicking the “Proceed Anyway” gets old. At least with Safari or Firefox, you can trust the cert and be done with it.

Google Chrome Self-Signed Certificate Error

The good news is that until they add some cert trust management into Chrome, you can at least pass a command-line flag to Google Chrome to ignore cert errors. Here is a great list of the various command-line flags or options you can pass to Google Chrome. But starting Chrome or other applications from Terminal is not usually what I do when I am in OS X.

"Fun" way to open an OS X application executable with command-line options

The other typical way to change an OS X application settings at launch is to modify the Info.plist. But, after trying to pass some environmental variables to the application via that method in adding dictionary keys, I had to try something else. Even if I could get something to stick and have Chrome recognize the command-line args via the Info.plist under the app “Contents” directory, there was the probability I would need to mess with it over and over again each update. Not fun.

Enter Platypus.

Platypus has been around for years and allows you to quickly and easily generate a new executable .app that references other application but can merge with shell scripts or other stuff to get around the limitations of not being able to access functions lost when applications are ported to OS X.

Generating a new .app via Platypus that makes a call to start the executable in the Contents of the OS X app and an external shell script is a great way around this because the shell script and app will still work as long as the path to the Google Chrome Canary.app stays consistent from update to update.

Once in Platypus, I created a shell script that it places by default under the ~/Library/Application/Support/Platypus. The script makes a call to the executable and adds the flag that I wanted to nix the cert warnings.

Script to start Google Chrome Canary with the command-line arg in OS X

You can also test the syntax in the application.

Checking syntax of the script for errors.

After you get what you want, you can save the project as an application. I named my “ChromeHelper.app” and saved in the /Applications directory. This is the launcher I will use that starts Chrome Canary with the additional option. You can also snag the icon for the application from the real application “Get Info” dialogue then paste it into the Platypus interface to give the app a “custom icon.”

Creating the OS X .app in Platypus

After saving, you get an application wrapper that gives to the additional layer of code to pass the args to the executable. Super handy. Here is what the “Get Info” window looks like after the app creation via Platypus.

Dropping the app in your dock or creating a shortcut will have it act just like the original app, but with the additional options. Pretty cool and a great way to get around the one weakness in the application until they add the functionality or Mozilla gets their act together to make Firefox the best browser again one day.

Leave a comment or reply