Skip to content

public.open.resource

Yoann Gini edited this page Apr 11, 2023 · 6 revisions

Function description

Goal

This function is used to open any URL scheme recognized by OS X.

Settings

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

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+)
URL String Target's URL to open
hideIfNotAvailable Boolean For file:// URL scheme only, menu item will be hidden if the resource does not exist (supported in Hello-IT 1.7.0+)

The URL scheme must be recognized by OS X and correctly associated with an application. You can test if your system support your URL correctly with Safari. Type your URL in the Safari URL field and it will try to open it. If Safari can't open it by itself it will open it via default application.

If you want to list all know scheme in your system, you can use:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump | grep 'flags\|bindings' | grep -A1 'url-type' | grep 'bindings' | cut -d\  -f2-

Sample settings

<dict>
	<key>functionIdentifier</key>
	<string>public.open.resource</string>
	<key>settings</key>
	<dict>
		<key>URL</key>
		<string>https://www.dropbox.com/sso/42</string>
		<key>title</key>
		<string>Dropbox Business</string>
	</dict>
</dict>
<dict>
	<key>functionIdentifier</key>
	<string>public.open.resource</string>
	<key>settings</key>
	<dict>
		<key>URL</key>
		<string>rdp://vdi.corp.example.com</string>
		<key>title</key>
		<string>Your Windows Desktop</string>
	</dict>
</dict>

More informations

Main implementation

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

The original implementation use NSURL and NSWorkspace classes from the Cocoa framework.

That mean the URL string must be a URL that conforms to RFCs 2396, 1738 and 1808.