Docs

System preferences (window.Electron.systemPreferences)

OS accent color, named system colors, effective light/dark appearance, and camera/microphone permission status, wrapping Electron's systemPreferences module. Source: src/main/system-preferences.ts, channel prefix systemPreferences:*. Always on, no config needed.

Most of this module is Windows/macOS-only at the Electron level, and Electron itself throws when a platform doesn't implement a given getter. Rather than surface a platform-specific stack trace, every method here catches that case and returns a neutral fallback (null or 'unknown') instead — "unsupported" and "no answer" collapse into the same shape, so you don't need per-platform try/catch just to call these.

Methods

Method Returns Notes
getAccentColor() Promise<string | null> Windows/macOS only. Hex color string, or null when unsupported/unavailable.
getColor(color: string) Promise<string | null> Windows/macOS only. color is a named system color, e.g. 'window' or 'highlight' — see Electron's systemPreferences.getColor() docs for the full list. null when unsupported.
getEffectiveAppearance() Promise<'dark' | 'light' | 'unknown'> macOS only. Falls back to 'unknown' elsewhere — prefer window.Electron.nativeTheme for cross-platform theme detection.
getMediaAccessStatus(mediaType: 'microphone' | 'camera' | 'screen') Promise<'not-determined' | 'granted' | 'denied' | 'restricted' | 'unknown'>
askForMediaAccess(mediaType: 'microphone' | 'camera') Promise<boolean> macOS only — prompts the OS permission dialog. Resolves false on other platforms instead of rejecting. Not valid for 'screen' — screen-recording access is granted through the OS's own settings panel, not an in-app prompt.

Example

const accent = await window.Electron.systemPreferences.getAccentColor(); // '#0078d7' or null
const status = await window.Electron.systemPreferences.getMediaAccessStatus('camera');
if (status !== 'granted') {
  await window.Electron.systemPreferences.askForMediaAccess('camera');
}

.safe

Fully mirrored — window.Electron.safe.systemPreferences.* resolves { ok: true, data } / { ok: false, error } instead of throwing. In practice these methods rarely produce { ok: false } themselves (unsupported platforms already resolve a neutral value rather than an error) — .safe here mainly guards against the shared FORBIDDEN/UNKNOWN cases every channel can hit.

Last updated on July 18, 2026