public static class MacOSAccentThe accent colour macOS is set to, read out of AppKit's semantic colours.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
+[NSColor controlAccentColor], and not AppleAccentColor in NSUserDefaults. The defaults key is an index rather than a colour — one of eight, with the key absent altogether when the user has never moved off the default — so a reader built on it needs a hard-coded table of Apple's eight accent colours plus a ninth answer for "absent", and every one of those nine is a value Apple owns and this repository would be guessing at. The semantic colour is the same choice resolved by the system that made it.
⚠ Absence is the common case on the defaults path and is the reason it is not taken. Measured on a stock macOS 15 machine: AppleAccentColor and AppleHighlightColor are both missing while AppleInterfaceStyle reads Dark. A reader over the defaults would therefore answer "no accent" on almost every Mac; controlAccentColor answers the blue that machine is actually drawing.
⚠ AppKit, from a process with no NSApplication, and that is measured rather than assumed. Three files in this repository recorded that the platform's palette could not be read because "an SDL process has no NSApplication and NSColor wants one". It is false — a semantic colour is a class method resolved against NSAppearance.currentDrawingAppearance, which has a sensible value with no application object in sight, and it works on a secondary thread. MacOSSemanticColorTests is the tripwire under that correction and this reader is its first production caller. What genuinely does need an NSApplication is NSApp.effectiveAppearance, which is why MacOSAppearance reads a default instead.
⚠ The accent does not follow the appearance and the text on it does. controlAccentColor is the user's choice and reads the same under Aqua and Dark Aqua — asserted, because two identical readings are also what a broken prototype returns — so this needs no appearance set and is correct whichever one is current. alternateSelectedControlTextColor is the white AppKit draws on a selected row and is what pairs with it.
Returned in sRGB, because SystemAccent is: the conversion to linear happens once, at the PlatformInput boundary that knows what a SystemPalette holds.
Methods (1)
public static SystemAccent Read()Reads the accent colour.
Used by (2)
- DesktopAppearanceVixen.Platform.Desktop
- MacOSAccentTestsVixen.Platform.MacOS.Tests