Reputation: 1213
Much like Safari, trying to implement a button that when clicked opens System Preferences > Extensions > Share Menu pane.
I have tried:
NSURL *URL = [NSURL URLWithString:@"x-apple.systempreferences:com.apple.preferences.extensions?Share_Menu"];
[[NSWorkspace sharedWorkspace] openURL:URL];
However it seems like that is not working on newer versions, any ideas?
Upvotes: 2
Views: 239
Reputation: 2492
Since macOS Ventura (13.0) you can call the URL
x-apple.systempreferences:com.apple.preferences.extensions?Sharing
Upvotes: 0
Reputation: 5320
You can use Scripting Bridge to do something like this:
SBSystemPreferencesApplication *systemPrefs =
[SBApplication applicationWithBundleIdentifier:@"com.apple.systempreferences"];
[systemPrefs activate];
SBElementArray *panes = [systemPrefs panes];
SBSystemPreferencesPane *notificationsPane = nil;
for (SBSystemPreferencesPane *pane in panes) {
if ([[pane id] isEqualToString:@"com.apple.preferences.extensions"]) {
notificationsPane = pane;
break;
}
}
[systemPrefs setCurrentPane:notificationsPane];
SBElementArray *anchors = [notificationsPane anchors];
for (SBSystemPreferencesAnchor *anchor in anchors) {
if ([anchor.name isEqualToString:@"Extensions"]) {
[anchor reveal];
}
}
Of course you need to add the ScriptingBridge framework to your project and a Scripting Bridge header file for system preferences. More details on how to use Scripting Bridge you can find in the developer documentation from Apple.
Hope this helps
Upvotes: 1