Skip to content

ElectronSystemPreferences

Unofficial

Electron SystemPreferences for reading and writing system-wide preferences.

Import:

import type { ElectronSystemPreferences } from '@obsidian-typings/obsidian-public-latest';

Signature:

export interface ElectronSystemPreferences

Properties

Property Type Description
appLevelAppearance 'dark' | 'light' | 'unknown' A string property that can be dark, light or unknown. It determines the macOS appearance setting for your application. This maps to values in NSApplication.appearance. Setting this will override the system default as well as the value of getEffectiveAppearance.

Platform: darwin.
effectiveAppearance 'dark' | 'light' | 'unknown' A string property that can be dark, light or unknown. Returns the macOS appearance setting that is currently applied to your application, maps to NSApplication.effectiveAppearance.

Platform: darwin.

Methods

Method Returns Description
addListener(event, listener) this Adds a listener for the accent-color-changed event.
addListener(event, listener) this Adds a listener for the color-changed event.
addListener(event, listener) this Adds a listener for the high-contrast-color-scheme-changed event.
addListener(event, listener) this Adds a listener for the inverted-color-scheme-changed event.
askForMediaAccess(mediaType) Promise<boolean> Prompts the user for access to the given media type. Resolves with true if consent was granted and false if it was denied.
canPromptTouchID() boolean Returns whether or not this device has the ability to use Touch ID.
getAccentColor() string Returns the user's current system wide accent color preference in RGBA hexadecimal form.
getAnimationSettings() ElectronAnimationSettings Returns an object with the system animation settings.
getAppLevelAppearance() 'dark' | 'light' | 'unknown' Gets the macOS appearance setting that you have declared you want for your application, maps to NSApplication.appearance. Can be dark, light or unknown.
getColor(color) string Returns the system color setting in RGB hexadecimal form (#ABCDEF).
getEffectiveAppearance() 'dark' | 'light' | 'unknown' Gets the macOS appearance setting that is currently applied to your application, maps to NSApplication.effectiveAppearance. Can be dark, light or unknown.
getMediaAccessStatus(mediaType) 'denied' | 'granted' | 'not-determined' | 'restricted' | 'unknown' Returns the access status for the given media type. Can be not-determined, granted, denied, restricted or unknown.
getSystemColor(color) string Returns one of several standard system colors that automatically adapt to vibrancy and changes in accessibility settings. The standard system color is formatted as #RRGGBBAA.
getUserDefault(key, type) ElectronUserDefaultTypes[Type] Returns the value of key in NSUserDefaults.
isAeroGlassEnabled() boolean Returns true if DWM composition (Aero Glass) is enabled, and false otherwise.
isDarkMode() boolean Returns whether the system is in Dark Mode.
isHighContrastColorScheme() boolean Returns true if a high contrast theme is active, false otherwise.
isInvertedColorScheme() boolean Returns true if an inverted color scheme (a high contrast color scheme with light text and dark backgrounds) is active, false otherwise.
isSwipeTrackingFromScrollEventsEnabled() boolean Returns whether the Swipe between pages setting is on.
isTrustedAccessibilityClient(prompt) boolean Returns true if the current process is a trusted accessibility client and false if it is not.
on('accent-color-changed', listener) this Registers a listener for the accent-color-changed event.
on('color-changed', listener) this Registers a listener for the color-changed event.
on('high-contrast-color-scheme-changed', listener) this Registers a listener for the high-contrast-color-scheme-changed event.
on('inverted-color-scheme-changed', listener) this Registers a listener for the inverted-color-scheme-changed event.
once(event, listener) this Registers a one-time listener for the accent-color-changed event. The listener is removed after it is invoked once.
once(event, listener) this Registers a one-time listener for the color-changed event. The listener is removed after it is invoked once.
once(event, listener) this Registers a one-time listener for the high-contrast-color-scheme-changed event. The listener is removed after it is invoked once.
once(event, listener) this Registers a one-time listener for the inverted-color-scheme-changed event. The listener is removed after it is invoked once.
postLocalNotification(event, userInfo) void Posts event as native notifications of macOS. The userInfo is an object that contains the user information dictionary sent along with the notification.
postNotification(event, userInfo, deliverImmediately?) void Posts event as native notifications of macOS. The userInfo is an object that contains the user information dictionary sent along with the notification.
postWorkspaceNotification(event, userInfo) void Posts event as native notifications of macOS. The userInfo is an object that contains the user information dictionary sent along with the notification.
promptTouchID(reason) Promise<void> Prompts the user to authenticate with Touch ID. Resolves if the user has successfully authenticated with Touch ID.
registerDefaults(defaults) void Adds the specified defaults to your application's NSUserDefaults.
removeListener(event, listener) this Removes the specified listener for the accent-color-changed event.
removeListener(event, listener) this Removes the specified listener for the color-changed event.
removeListener(event, listener) this Removes the specified listener for the high-contrast-color-scheme-changed event.
removeListener(event, listener) this Removes the specified listener for the inverted-color-scheme-changed event.
removeUserDefault(key) void Removes the key in NSUserDefaults. This can be used to restore the default or global value of a key previously set with setUserDefault.
setAppLevelAppearance(appearance) void Sets the appearance setting for your application, this should override the system default and override the value of getEffectiveAppearance.
setUserDefault(key, type, value) void Sets the value of key in NSUserDefaults. Note that type should match the actual type of value. An exception is thrown if they don't.
subscribeLocalNotification(event, callback) number Same as subscribeNotification, but uses NSNotificationCenter for local defaults. If event is null, the NSNotificationCenter doesn't use it as criteria for delivery to the observer.
subscribeNotification(event, callback) number Subscribes to native notifications of macOS, callback will be called with callback(event, userInfo) when the corresponding event happens. If event is null, the NSDistributedNotificationCenter doesn't use it as criteria for delivery to the observer.
subscribeWorkspaceNotification(event, callback) number Same as subscribeNotification, but uses NSWorkspace.sharedWorkspace.notificationCenter. If event is null, the NSWorkspaceNotificationCenter doesn't use it as criteria for delivery to the observer.
unsubscribeLocalNotification(id) void Same as unsubscribeNotification, but removes the subscriber from NSNotificationCenter.
unsubscribeNotification(id) void Removes the subscriber with id.
unsubscribeWorkspaceNotification(id) void Same as unsubscribeNotification, but removes the subscriber from NSWorkspace.sharedWorkspace.notificationCenter.

Links to this page: