Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save usagimaru/a9ca8c6cc5242827af6d13946080ce87 to your computer and use it in GitHub Desktop.
Save usagimaru/a9ca8c6cc5242827af6d13946080ce87 to your computer and use it in GitHub Desktop.
Get the "Show toolbar button shapes" option flag of the macOS system accessibility settings (using private API)
// "accessibilityDisplayShouldShowToolbarButtonShapes" changes will call this notification.
NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.accessibilityDisplayOptionsDidChangeNotification,
object: NSWorkspace.shared,
queue: nil) { notif in
// Get the current flag
// The property of NSSWorkspaceAccessibilityDisplay "accessoryDisplayShouldShowToolbarButtonShapes" is private on macOS 13.
let flag = NSWorkspace.shared.value(forKey: "accessibilityDisplayShouldShowToolbarButtonShapes")!
print("\(flag)")
}
@usagimaru
Copy link
Author

システム設定 > アクセシビリティ > ディスプレイにある「ツールバーボタンに輪郭を表示」の状態をBool値で取得します。AppKitでは公開APIが無く、accessibilityDisplayShouldShowToolbarButtonShapesをキーとした値オブジェクトを取得する必要があります。

スクリーンショット 2024-02-23 7 08 58

@usagimaru
Copy link
Author

usagimaru commented Feb 25, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment