如何使用捆绑标识符将系统偏好设置启动到特定偏好设置面板?



我正在尝试直接从我的应用程序打开系统日期和时间首选项。 我似乎可以使用以下方法毫无问题地打开系统偏好设置:

let settingsBundleIdentifier = "com.apple.systempreferences"
NSWorkspace.shared.launchApplication(withBundleIdentifier: settingsBundleIdentifier, options: [], additionalEventParamDescriptor: nil, launchIdentifier: nil)

但是我不知道如何直接转到日期和时间窗格。

我尝试将捆绑标识符更改为com.apple.systempreferences:com.apple.datetimeprefcom.apple.systempreferences:com.apple.preference.datetime无济于事。

我应该在这里做什么? 不能直接通过捆绑标识符打开窗格吗?

我知道我可以直接使用文件路径打开首选项窗格以DateTime.prefPane。但是我希望使用捆绑标识符打开它。

2023

:任何需要的首选项窗格(.prefPane(:

NSWorkspace.shared.open(URL(fileURLWithPath: "/System/Library/PreferencePanes/%PrefsNsme%.prefPane"))

%PrefsNsme%替换为位于以下位置的任何所需文件名:

/System/Library/PreferencePanes/

systemPrefs:

NSWorkspace.shared.open(URL(string: "x-apple.systempreferences:com.apple.preference")!)

某些系统偏好设置实际上被分组为扩展,并使用以下格式调用:

NSWorkspace.shared.open(URL(string: "x-apple.systempreferences:com.apple.%ExtensionName%)!)

扩展列表精选自:

/System/Applications/SystemSettings.app/Contents/Resources/Sidebar.plist

用于参考的扩展 URL 列表 [macOS Ventura]。有些使用 .extension 有些不使用:

Family Settings: x-apple.systempreferences:com.apple.Family-Settings.extension
Software Update: x-apple.systempreferences:com.apple.FollowUpSettings.FollowUpSettingsExtension
Wifi: x-apple.systempreferences:com.apple.wifi-settings-extension
Bluetooth: x-apple.systempreferences:com.apple.BluetoothSettings
Network: x-apple.systempreferences:com.apple.Network-Settings.extension
Classroom Settings: x-apple.systempreferences:com.apple.ClassroomSettings
Classroom Settings2: x-apple.systempreferences:com.apple.Classroom-Settings.extension
Notifications: x-apple.systempreferences:com.apple.Notifications-Settings.extension
Sound: x-apple.systempreferences:com.apple.Sound-Settings.extension
Focus: x-apple.systempreferences:com.apple.Focus-Settings.extension
Screen Time: x-apple.systempreferences:com.apple.Screen-Time-Settings.extension
Appearance: x-apple.systempreferences:com.apple.Appearance-Settings.extension
Accessibility: x-apple.systempreferences:com.apple.Accessibility-Settings.extension
Control Center: x-apple.systempreferences:com.apple.ControlCenter-Settings.extension
Siri: x-apple.systempreferences:com.apple.Siri-Settings.extension
Spotlight: x-apple.systempreferences:com.apple.Spotlight-Settings.extension
Privacy Security: x-apple.systempreferences:com.apple.settings.PrivacySecurity.extension
Desktop: x-apple.systempreferences:com.apple.Desktop-Settings.extension
Displays: x-apple.systempreferences:com.apple.Displays-Settings.extension
Wallpaper: x-apple.systempreferences:com.apple.Wallpaper-Settings.extension
Screen Saver: x-apple.systempreferences:com.apple.ScreenSaver-Settings.extension
Battery: x-apple.systempreferences:com.apple.Battery-Settings.extension
Lock Screen: x-apple.systempreferences:com.apple.Lock-Screen-Settings.extension
Touch ID: x-apple.systempreferences:com.apple.Touch-ID-Settings.extension
Users Groups: x-apple.systempreferences:com.apple.Users-Groups-Settings.extension
Passwords: x-apple.systempreferences:com.apple.Passwords-Settings.extension
Passwords2: x-apple.systempreferences:com.apple.Passwords
Internet Accounts: x-apple.systempreferences:com.apple.Internet-Accounts-Settings.extension
Game Center: x-apple.systempreferences:com.apple.Game-Center-Settings.extension
Wallet: x-apple.systempreferences:com.apple.WalletSettingsExtension
Keyboard: x-apple.systempreferences:com.apple.Keyboard-Settings.extension
Mouse: x-apple.systempreferences:com.apple.Mouse-Settings.extension
Trackpad: x-apple.systempreferences:com.apple.Trackpad-Settings.extension
Game Controller: x-apple.systempreferences:com.apple.Game-Controller-Settings.extension
CD-DVD: x-apple.systempreferences:com.apple.CD-DVD-Settings.extension
Print Scan: x-apple.systempreferences:com.apple.Print-Scan-Settings.extension

供参考的网址列表[针对macOS Ventura更新]:

Accessibility Preference Pane
Main    x-apple.systempreferences:com.apple.preference.universalaccess
Display x-apple.systempreferences:com.apple.preference.universalaccess?Seeing_Display
Zoom    x-apple.systempreferences:com.apple.preference.universalaccess?Seeing_Zoom
VoiceOver   x-apple.systempreferences:com.apple.preference.universalaccess?Seeing_VoiceOver
Descriptions    x-apple.systempreferences:com.apple.preference.universalaccess?Media_Descriptions
Captions    x-apple.systempreferences:com.apple.preference.universalaccess?Captioning
Audio   x-apple.systempreferences:com.apple.preference.universalaccess?Hearing
Keyboard    x-apple.systempreferences:com.apple.preference.universalaccess?Keyboard
Mouse & Trackpad    x-apple.systempreferences:com.apple.preference.universalaccess?Mouse
Switch Control  x-apple.systempreferences:com.apple.preference.universalaccess?Switch
Dictation   x-apple.systempreferences:com.apple.preference.universalaccess?SpeakableItems
Security & Privacy Preference Pane
Main    x-apple.systempreferences:com.apple.preference.security
General x-apple.systempreferences:com.apple.preference.security?General
FileVault   x-apple.systempreferences:com.apple.preference.security?FDE
Firewall    x-apple.systempreferences:com.apple.preference.security?Firewall
Advanced    x-apple.systempreferences:com.apple.preference.security?Advanced
Privacy x-apple.systempreferences:com.apple.preference.security?Privacy
Privacy-Camera x-apple.systempreferences:com.apple.preference.security?Privacy_Camera
Privacy-Microphone  x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone
Privacy-Automation  x-apple.systempreferences:com.apple.preference.security?Privacy_Automation
Privacy-AllFiles    x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles
Privacy-Accessibility   x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility
Privacy-Assistive   x-apple.systempreferences:com.apple.preference.security?Privacy_Assistive
Privacy-Location Services   x-apple.systempreferences:com.apple.preference.security?Privacy_LocationServices
Privacy-SystemServices  x-apple.systempreferences:com.apple.preference.security?Privacy_SystemServices
Privacy-Advertising x-apple.systempreferences:com.apple.preference.security?Privacy_Advertising
Privacy-Contacts    x-apple.systempreferences:com.apple.preference.security?Privacy_Contacts
Privacy-Diagnostics & Usage x-apple.systempreferences:com.apple.preference.security?Privacy_Diagnostics
Privacy-Calendars   x-apple.systempreferences:com.apple.preference.security?Privacy_Calendars
Privacy-Reminders   x-apple.systempreferences:com.apple.preference.security?Privacy_Reminders
Privacy-Facebook    x-apple.systempreferences:com.apple.preference.security?Privacy_Facebook
Privacy-LinkedIn    x-apple.systempreferences:com.apple.preference.security?Privacy_LinkedIn
Privacy-Twitter x-apple.systempreferences:com.apple.preference.security?Privacy_Twitter
Privacy-Weibo   x-apple.systempreferences:com.apple.preference.security?Privacy_Weibo
Privacy-Tencent Weibo   x-apple.systempreferences:com.apple.preference.security?Privacy_TencentWeibo
macOS Catalina 10.15:
Privacy-ScreenCapture   x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture
Privacy-DevTools    x-apple.systempreferences:com.apple.preference.security?Privacy_DevTools
Privacy-InputMonitoring x-apple.systempreferences:com.apple.preference.security?Privacy_ListenEvent
Privacy-DesktopFolder   x-apple.systempreferences:com.apple.preference.security?Privacy_DesktopFolder
Privacy-DocumentsFolder x-apple.systempreferences:com.apple.preference.security?Privacy_DocumentsFolder
Privacy-DownloadsFolder x-apple.systempreferences:com.apple.preference.security?Privacy_DownloadsFolder
Privacy-NetworkVolume   x-apple.systempreferences:com.apple.preference.security?Privacy_NetworkVolume
Privacy-RemovableVolume x-apple.systempreferences:com.apple.preference.security?Privacy_RemovableVolume
Privacy-SpeechRecognition   x-apple.systempreferences:com.apple.preference.security?Privacy_SpeechRecognition
Privacy-DevTools    x-apple.systempreferences:com.apple.preference.security?Privacy_DevTools
macOS Big Sur 10.11/10.16:
Privacy-Bluetooth   x-apple.systempreferences:com.apple.preference.security?Privacy_Bluetooth
Privacy-Music   x-apple.systempreferences:com.apple.preference.security?Privacy_Media
Privacy-Home    x-apple.systempreferences:com.apple.preference.security?Privacy_HomeKit

Dictation & Speech Preference Pane
Dictation   x-apple.systempreferences:com.apple.preference.speech?Dictation
Text to Speech  x-apple.systempreferences:com.apple.preference.speech?TTS
Sharing Preference Pane
Main    x-apple.systempreferences:com.apple.preferences.sharing
Screen Sharing  x-apple.systempreferences:com.apple.preferences.sharing?Services_ScreenSharing
File Sharing    x-apple.systempreferences:com.apple.preferences.sharing?Services_PersonalFileSharing
Printer Sharing x-apple.systempreferences:com.apple.preferences.sharing?Services_PrinterSharing
Remote Login    x-apple.systempreferences:com.apple.preferences.sharing?Services_RemoteLogin
Remote Management   x-apple.systempreferences:com.apple.preferences.sharing?Services_ARDService
Remote Apple Events x-apple.systempreferences:com.apple.preferences.sharing?Services_RemoteAppleEvent
Internet Sharing    x-apple.systempreferences:com.apple.preferences.sharing?Internet
Bluetooth Sharing   x-apple.systempreferences:com.apple.preferences.sharing?Services_BluetoothSharing
Software update x-apple.systempreferences:com.apple.preferences.softwareupdate?client=softwareupdateapp
macOS Monterey 12.0:
Privacy-DoNotDisturb    x-apple.systempreferences:com.apple.preference.security?Privacy_Focus
macOS Ventura 13.0:
Privacy-AppBundles    x-apple.systempreferences:com.apple.preference.security?Privacy_AppBundles
Privacy-ListenEvent    x-apple.systempreferences:com.apple.preference.security?Privacy_ListenEvent
Dictation & Speech Preference Pane
Dictation   x-apple.systempreferences:com.apple.preference.speech?Dictation
Text to Speech  x-apple.systempreferences:com.apple.preference.speech?TTS
Sharing Preference Pane
Main    x-apple.systempreferences:com.apple.preferences.sharing
Screen Sharing  x-apple.systempreferences:com.apple.preferences.sharing?Services_ScreenSharing
File Sharing    x-apple.systempreferences:com.apple.preferences.sharing?Services_PersonalFileSharing
Printer Sharing x-apple.systempreferences:com.apple.preferences.sharing?Services_PrinterSharing
Remote Login    x-apple.systempreferences:com.apple.preferences.sharing?Services_RemoteLogin
Remote Management   x-apple.systempreferences:com.apple.preferences.sharing?Services_ARDService
Remote Apple Events x-apple.systempreferences:com.apple.preferences.sharing?Services_RemoteAppleEvent
Internet Sharing    x-apple.systempreferences:com.apple.preferences.sharing?Internet
Bluetooth Sharing   x-apple.systempreferences:com.apple.preferences.sharing?Services_BluetoothSharing
Software update x-apple.systempreferences:com.apple.preferences.softwareupdate?client=softwareupdateapp
//https://stackoverflow.com/a/48139877/4423545

我找到了以下代码来打开安全PrefPane到某个页面:

let prefpaneUrl = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")!
NSWorkspace.shared.open(prefpaneUrl)

但奇怪的是,当我尝试相同的日期和时间时

let prefpaneUrl = URL(string: "x-apple.systempreferences:com.apple.preference.datetime"
NSWorkspace.shared.open(prefpaneUrl)

它不起作用,如果我使用日期和时间PrefPane的捆绑标识符,也不起作用:

let prefpaneUrl = URL(string: "x-apple.systempreferences:system.preferences.datetime")!
NSWorkspace.shared.open(prefpaneUrl)

更新:这里有一个工作偏好窗格标识符的列表:http://web.archive.org/web/20190606022433/https://macosxautomation.com/system-prefs-links.html 似乎日期和时间只是没有暴露。

相关内容

  • 没有找到相关文章

最新更新