I was playing with hook to add support for System Preferences deep linking (which Apple calls them Anchors) here’s the result:
you can open System Preferences panes and anchors with this url scheme:
open "x-apple.systempreferences:com.apple.preferences.sharing?Services_ScreenSharing"
Notice it is x-apple.systempreferences:
and not x-apple.systempreferences://
which currently Hook
does not support as of version 3.1
So as a workaround we will add our own scheme
After the following steps you will be able to copy and open System Preferences Panes / Anchors (Deep Links) e.g. System Preferences → Spotlight (privacy)
-
Add
x-hook.systempreferences
inScript Editor → Open Item → scheme
-
Add the following script to
Script Editor → Open Item
//JavaScript const app = Application("System Preferences"); app.includeStandardAdditions = true; app.activate(); const [_, paneId, anchorId] = /(?::\/\/)([^?]+)?(?:\?(.*))?$/.exec("$0"); const pane = paneId ? app.panes.byId(paneId) : null; const anchor = anchorId && pane ? pane.anchors.byName(anchorId) : null app.reveal(anchor || pane);
-
Add the following script to
Script Editor → Get Address
//JavaScript /* Apple's URL Scheme: x-apple.systempreferences:com.apple.preferences.sharing?Services_ScreenSharing More Info: https://stackoverflow.com/a/24703872 */ const app = Application("System Preferences"); app.includeStandardAdditions = true; const pane = app.currentPane(); let anchor = pane ? app.chooseFromList(pane.anchors().map(a => a.name()), { withPrompt: 'Select an Anchor' }) : null; anchor = anchor && anchor.length > 0 && anchor[0] || ""; let paneId = pane && pane.id() || ""; let name = "System Preferences"; name = pane ? `${name} → ${pane.name()}` : name; name = anchor ? `${name} (${anchor})` : name; `[${name}](x-hook.systempreferences://${paneId}?${anchor})`