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

PropertyTypeDescription
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

MethodReturnsDescription
addListener(event, listener)thisAdds a listener for the accent-color-changed event.
addListener(event, listener)thisAdds a listener for the color-changed event.
addListener(event, listener)thisAdds a listener for the high-contrast-color-scheme-changed event.
addListener(event, listener)thisAdds 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()booleanReturns whether or not this device has the ability to use Touch ID.
getAccentColor()stringReturns the user's current system wide accent color preference in RGBA hexadecimal form.
getAnimationSettings()ElectronAnimationSettingsReturns 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)stringReturns 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)stringReturns 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()booleanReturns true if DWM composition (Aero Glass) is enabled, and false otherwise.
isDarkMode()booleanReturns whether the system is in Dark Mode.
isHighContrastColorScheme()booleanReturns true if a high contrast theme is active, false otherwise.
isInvertedColorScheme()booleanReturns true if an inverted color scheme (a high contrast color scheme with light text and dark backgrounds) is active, false otherwise.
isSwipeTrackingFromScrollEventsEnabled()booleanReturns whether the Swipe between pages setting is on.
isTrustedAccessibilityClient(prompt)booleanReturns true if the current process is a trusted accessibility client and false if it is not.
on('accent-color-changed', listener)thisRegisters a listener for the accent-color-changed event.
on('color-changed', listener)thisRegisters a listener for the color-changed event.
on('high-contrast-color-scheme-changed', listener)thisRegisters a listener for the high-contrast-color-scheme-changed event.
on('inverted-color-scheme-changed', listener)thisRegisters a listener for the inverted-color-scheme-changed event.
once(event, listener)thisRegisters a one-time listener for the accent-color-changed event. The listener is removed after it is invoked once.
once(event, listener)thisRegisters a one-time listener for the color-changed event. The listener is removed after it is invoked once.
once(event, listener)thisRegisters a one-time listener for the high-contrast-color-scheme-changed event. The listener is removed after it is invoked once.
once(event, listener)thisRegisters a one-time listener for the inverted-color-scheme-changed event. The listener is removed after it is invoked once.
postLocalNotification(event, userInfo)voidPosts 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?)voidPosts 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)voidPosts 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)voidAdds the specified defaults to your application's NSUserDefaults.
removeListener(event, listener)thisRemoves the specified listener for the accent-color-changed event.
removeListener(event, listener)thisRemoves the specified listener for the color-changed event.
removeListener(event, listener)thisRemoves the specified listener for the high-contrast-color-scheme-changed event.
removeListener(event, listener)thisRemoves the specified listener for the inverted-color-scheme-changed event.
removeUserDefault(key)voidRemoves the key in NSUserDefaults. This can be used to restore the default or global value of a key previously set with setUserDefault.
setAppLevelAppearance(appearance)voidSets the appearance setting for your application, this should override the system default and override the value of getEffectiveAppearance.
setUserDefault(key, type, value)voidSets 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)numberSame 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)numberSubscribes 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)numberSame 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)voidSame as unsubscribeNotification, but removes the subscriber from NSNotificationCenter.
unsubscribeNotification(id)voidRemoves the subscriber with id.
unsubscribeWorkspaceNotification(id)voidSame as unsubscribeNotification, but removes the subscriber from NSWorkspace.sharedWorkspace.notificationCenter.

Links to this page: