Skip to content

public.open.application

Yoann Gini edited this page Apr 18, 2021 · 8 revisions

Function description

Goal

This function is used to open an OS X application, eventually with a file.

Settings

The settings dictionary contain all informations you can set to use this function. Here is a description of each.

To specify the app to open, two scenarios are available, an app name and an optional file path to open with OR an app path with custom args.

Key Type Description
title Translatable string (see: Label translation) Item's title shown in the menu
computedTitle Name of the script in Application Support CustomScripts folder First line on stdout will be the title
optionalDisplay Boolean Will show the related item only if option key was pressed when Hello-IT menu was shown (supported in Hello-IT 1.4.0+)
hideIfNotAvailable Boolean Set to true, the menu item will be hidden if the target app isn't available on the local system. Default is false.
app String Name of the application on disk without .app (TextEdit for example)
file String (optional) Full path of a file you want to open with the application (~ supported), to use with app
appURL String Absolute path for the target application
args Array of string (optional) Arguments to pass to the application, to use with appURL

You can only use app with file or appURL with args.

Sample settings

<dict>
	<key>functionIdentifier</key>
	<string>public.open.application</string>
	<key>settings</key>
	<dict>
		<key>app</key>
		<string>Managed Software Center</string>
		<key>title</key>
		<dict>
			<key>en</key>
			<string>Managed Software Center</string>
			<key>fr</key>
			<string>Centre de gestion des logiciels</string>
		</dict>
	</dict>
</dict>

More informations

Main implementation

The main implementation of this function is made in the OpenApplication plugin from the main project.

The original implementation use NSWorkspace from the Cocoa framework.