如何确定macOS 10.14的配色? [英] How can I determine the macOS 10.14 accent color?
问题描述
MacOS 10.14(Mojave)具有深色的界面样式和用户可选的颜色强调.如何读取这些值并听取更改?
MacOS 10.14 (Mojave) features a Dark interface style, and user selectable color accents. How to read these values and listen for changes?
推荐答案
此内容存储在系统默认值中,可通过NSDistributedNotificationCenter
访问.
This is stored in the system defaults, available through NSDistributedNotificationCenter
.
暗模式有效.可以通过监听InterfaceStyleChanged
通知来观察更改.
Dark mode is active when AppleInterfaceStyle
is set to Dark
. Changes can be observed by listening for the InterfaceStyleChanged
notification.
可以从AppleAccentColor
中读取强调色.可以通过监听AppleColorPreferencesChangedNotification
通知来观察更改.两者都返回一个可选的整数,该整数映射到:
The accent color can be read from AppleAccentColor
. Changes can be observed by listening for the AppleColorPreferencesChangedNotification
notification. Both returns an optional integer, that maps to:
nil: blue
-1: graphite
0: red
1: orange
2: yellow
3: green
5: purple
6: pink
您可以通过运行defaults read -g AppleAccentColor
从终端或脚本中读取此值.请注意,如果该值为nil
(默认为蓝色),则实际上会显示一条错误消息,该错误显示为The domain/default pair of (kCFPreferencesAnyApplication, AppleAccentColor) does not exist
.
You can read this value from the terminal or a script by running defaults read -g AppleAccentColor
. Note that if the value is nil
(default blue) you actually get an error that reads The domain/default pair of (kCFPreferencesAnyApplication, AppleAccentColor) does not exist
.
针对macOS 11 Beta的更新
nil
现在是默认的 multicolor 外观,并且 blue 已移至4
.
nil
is now the default multicolor appearance, and blue has been moved to 4
.
nil: multicolor
-1: graphite
0: red
1: orange
2: yellow
3: green
4: blue
5: purple
6: pink
这篇关于如何确定macOS 10.14的配色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!