Header menu logo fable-electron-docs-api

systemPreferences Type

⚠ Process Availability: Main ✔ | Renderer ❌ | Utility ✔ | Exported ✔

Get system preferences.Process: Main, Utility

Static members

Static member Description

systemPreferences.askForMediaAccess mediaType

Full Usage: systemPreferences.askForMediaAccess mediaType

Parameters:
Returns: Promise<bool>
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

A promise that resolves with true if consent was granted and false if it was denied. If an invalid mediaType is passed, the promise will be rejected. If an access request was denied and later is changed through the System Preferences pane, a restart of the app will be required for the new permissions to take effect. If access has already been requested and denied, it must be changed through the preference pane; an alert will not pop up and the promise will resolve with the existing access status.Important: In order to properly leverage this API, you must set the NSMicrophoneUsageDescription and NSCameraUsageDescription strings in your app's Info.plist file. The values for these keys will be used to populate the permission dialogs so that the user will be properly informed as to the purpose of the permission request. See Electron Application Distribution for more information about how to set these in the context of Electron.This user consent was not required until macOS 10.14 Mojave, so this method will always return true if your system is running 10.13 High Sierra.

mediaType : MediaType
Returns: Promise<bool>

systemPreferences.canPromptTouchID ()

Full Usage: systemPreferences.canPromptTouchID ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

whether or not this device has the ability to use Touch ID.

Returns: bool

systemPreferences.effectiveAppearance

Full Usage: systemPreferences.effectiveAppearance

Returns: EffectiveAppearance

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ 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

Returns: EffectiveAppearance

systemPreferences.getAccentColor ()

Full Usage: systemPreferences.getAccentColor ()

Returns: string
Modifiers: inline

The users current system wide accent color preference in RGBA hexadecimal form.This API is only available on macOS 10.14 Mojave or newer.

Returns: string

systemPreferences.getAnimationSettings ()

Full Usage: systemPreferences.getAnimationSettings ()

Returns: GetAnimationSettings
Modifiers: inline

  • shouldRenderRichAnimation boolean - Returns true if rich animations should be rendered. Looks at session type (e.g. remote desktop) and accessibility settings to give guidance for heavy animations.* scrollAnimationsEnabledBySystem boolean - Determines on a per-platform basis whether scroll animations (e.g. produced by home/end key) should be enabled.* prefersReducedMotion boolean - Determines whether the user desires reduced motion based on platform APIs.Returns an object with system animation settings.

Returns: GetAnimationSettings

systemPreferences.getColor color

Full Usage: systemPreferences.getColor color

Parameters:
Returns: string
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

The system color setting in RGBA hexadecimal form (#RRGGBBAA). See the Windows docs and the macOS docs for more details.The following colors are only available on macOS 10.14: find-highlight, selected-content-background, separator, unemphasized-selected-content-background, unemphasized-selected-text-background, and unemphasized-selected-text.

color : Color
Returns: string

systemPreferences.getEffectiveAppearance ()

Full Usage: systemPreferences.getEffectiveAppearance ()

Returns: GetEffectiveAppearance
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Can be dark, light or unknown.Gets the macOS appearance setting that is currently applied to your application, maps to NSApplication.effectiveAppearance

Returns: GetEffectiveAppearance

systemPreferences.getMediaAccessStatus mediaType

Full Usage: systemPreferences.getMediaAccessStatus mediaType

Parameters:
Returns: GetMediaAccessStatus
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ✔ | LIN ❌ | MAS ❌

Can be not-determined, granted, denied, restricted or unknown.This user consent was not required on macOS 10.13 High Sierra so this method will always return granted. macOS 10.14 Mojave or higher requires consent for microphone and camera access. macOS 10.15 Catalina or higher requires consent for screen access.Windows 10 has a global setting controlling microphone and camera access for all win32 applications. It will always return granted for screen and for all media types on older versions of Windows.

mediaType : MediaType
Returns: GetMediaAccessStatus

systemPreferences.getSystemColor color

Full Usage: systemPreferences.getSystemColor color

Parameters:
Returns: string
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

The standard system color formatted as #RRGGBBAA.Returns one of several standard system colors that automatically adapt to vibrancy and changes in accessibility settings like 'Increase contrast' and 'Reduce transparency'. See Apple Documentation for more details.

color : Color
Returns: string

systemPreferences.getUserDefault (key, type)

Full Usage: systemPreferences.getUserDefault (key, type)

Parameters:
Returns: string
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

The value of key in NSUserDefaults.Some popular key and types are:* AppleInterfaceStyle: string* AppleAquaColorVariant: integer* AppleHighlightColor: string* AppleShowScrollBars: string* NSNavRecentPlaces: array* NSPreferredWebServices: dictionary* NSUserDictionaryReplacementItems: array

key : string
type : UserType
Returns: string

systemPreferences.isSwipeTrackingFromScrollEventsEnabled ()

Full Usage: systemPreferences.isSwipeTrackingFromScrollEventsEnabled ()

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Whether the Swipe between pages setting is on.

Returns: bool

systemPreferences.isTrustedAccessibilityClient prompt

Full Usage: systemPreferences.isTrustedAccessibilityClient prompt

Parameters:
    prompt : bool

Returns: bool
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ true if the current process is a trusted accessibility client and false if it is not.

prompt : bool
Returns: bool

systemPreferences.offAccentColorChanged handler

Full Usage: systemPreferences.offAccentColorChanged handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

handler : IOnAccentColorChanged -> unit

systemPreferences.offAccentColorChanged handler

Full Usage: systemPreferences.offAccentColorChanged handler

Parameters:
    handler : Event -> string -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

handler : Event -> string -> unit

systemPreferences.offColorChanged handler

Full Usage: systemPreferences.offColorChanged handler

Parameters:
    handler : Event -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

handler : Event -> unit

systemPreferences.onAccentColorChanged handler

Full Usage: systemPreferences.onAccentColorChanged handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

handler : IOnAccentColorChanged -> unit

systemPreferences.onAccentColorChanged handler

Full Usage: systemPreferences.onAccentColorChanged handler

Parameters:
    handler : Event -> string -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

handler : Event -> string -> unit

systemPreferences.onColorChanged handler

Full Usage: systemPreferences.onColorChanged handler

Parameters:
    handler : Event -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

handler : Event -> unit

systemPreferences.onceAccentColorChanged handler

Full Usage: systemPreferences.onceAccentColorChanged handler

Parameters:
Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

handler : IOnAccentColorChanged -> unit

systemPreferences.onceAccentColorChanged handler

Full Usage: systemPreferences.onceAccentColorChanged handler

Parameters:
    handler : Event -> string -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ✔ | MAS ❌

handler : Event -> string -> unit

systemPreferences.onceColorChanged handler

Full Usage: systemPreferences.onceColorChanged handler

Parameters:
    handler : Event -> unit

Modifiers: inline

⚠ OS Compatibility: WIN ✔ | MAC ❌ | LIN ❌ | MAS ❌

handler : Event -> unit

systemPreferences.postLocalNotification (event, userInfo)

Full Usage: systemPreferences.postLocalNotification (event, userInfo)

Parameters:
    event : string
    userInfo : Record<string, obj>

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Posts event as native notifications of macOS. The userInfo is an Object that contains the user information dictionary sent along with the notification.

event : string
userInfo : Record<string, obj>

systemPreferences.postNotification (event, userInfo, ?deliverImmediately)

Full Usage: systemPreferences.postNotification (event, userInfo, ?deliverImmediately)

Parameters:
    event : string
    userInfo : Record<string, obj>
    ?deliverImmediately : bool

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Posts event as native notifications of macOS. The userInfo is an Object that contains the user information dictionary sent along with the notification.

event : string
userInfo : Record<string, obj>
?deliverImmediately : bool

systemPreferences.postWorkspaceNotification (event, userInfo)

Full Usage: systemPreferences.postWorkspaceNotification (event, userInfo)

Parameters:
    event : string
    userInfo : Record<string, obj>

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Posts event as native notifications of macOS. The userInfo is an Object that contains the user information dictionary sent along with the notification.

event : string
userInfo : Record<string, obj>

systemPreferences.promptTouchID reason

Full Usage: systemPreferences.promptTouchID reason

Parameters:
    reason : string

Returns: Promise<unit>
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

resolves if the user has successfully authenticated with Touch ID.This API itself will not protect your user data; rather, it is a mechanism to allow you to do so. Native apps will need to set Access Control Constants like kSecAccessControlUserPresence on their keychain entry so that reading it would auto-prompt for Touch ID biometric consent. This could be done with node-keytar, such that one would store an encryption key with node-keytar and only fetch it if promptTouchID() resolves.

reason : string
Returns: Promise<unit>

systemPreferences.registerDefaults defaults

Full Usage: systemPreferences.registerDefaults defaults

Parameters:
    defaults : Record<string, U3<string, bool, float>>

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Add the specified defaults to your application's NSUserDefaults.

defaults : Record<string, U3<string, bool, float>>

systemPreferences.removeUserDefault key

Full Usage: systemPreferences.removeUserDefault key

Parameters:
    key : string

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Removes the key in NSUserDefaults. This can be used to restore the default or global value of a key previously set with setUserDefault.

key : string

systemPreferences.setUserDefault (key, type, value)

Full Usage: systemPreferences.setUserDefault (key, type, value)

Parameters:
    key : string
    type : UserType
    value : string

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Set the value of key in NSUserDefaults.Note that type should match actual type of value. An exception is thrown if they don't.Some popular key and types are:* ApplePressAndHoldEnabled: boolean

key : string
type : UserType
value : string

systemPreferences.subscribeLocalNotification (event, callback)

Full Usage: systemPreferences.subscribeLocalNotification (event, callback)

Parameters:
    event : Option<string>
    callback : string * Record<string, obj> * string -> unit

Returns: float
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

The ID of this subscriptionSame as subscribeNotification, but uses NSNotificationCenter for local defaults. This is necessary for events such as NSUserDefaultsDidChangeNotification.If event is null, the NSNotificationCenter doesn’t use it as criteria for delivery to the observer. See docs for more information.

event : Option<string>
callback : string * Record<string, obj> * string -> unit
Returns: float

systemPreferences.subscribeNotification (event, callback)

Full Usage: systemPreferences.subscribeNotification (event, callback)

Parameters:
    event : Option<string>
    callback : string * Record<string, obj> * string -> unit

Returns: float
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

The ID of this subscriptionSubscribes to native notifications of macOS, callback will be called with callback(event, userInfo) when the corresponding event happens. The userInfo is an Object that contains the user information dictionary sent along with the notification. The object is the sender of the notification, and only supports NSString values for now.The id of the subscriber is returned, which can be used to unsubscribe the event.Under the hood this API subscribes to NSDistributedNotificationCenter, example values of event are:* AppleInterfaceThemeChangedNotification* AppleAquaColorVariantChanged* AppleColorPreferencesChangedNotification* AppleShowScrollBarsSettingChangedIf event is null, the NSDistributedNotificationCenter doesn’t use it as criteria for delivery to the observer. See docs for more information.

event : Option<string>
callback : string * Record<string, obj> * string -> unit
Returns: float

systemPreferences.subscribeWorkspaceNotification (event, callback)

Full Usage: systemPreferences.subscribeWorkspaceNotification (event, callback)

Parameters:
    event : Option<string>
    callback : string * Record<string, obj> * string -> unit

Returns: float
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

The ID of this subscriptionSame as subscribeNotification, but uses NSWorkspace.sharedWorkspace.notificationCenter. This is necessary for events such as NSWorkspaceDidActivateApplicationNotification.If event is null, the NSWorkspaceNotificationCenter doesn’t use it as criteria for delivery to the observer. See docs for more information.

event : Option<string>
callback : string * Record<string, obj> * string -> unit
Returns: float

systemPreferences.unsubscribeLocalNotification id

Full Usage: systemPreferences.unsubscribeLocalNotification id

Parameters:
    id : int

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Same as unsubscribeNotification, but removes the subscriber from NSNotificationCenter.

id : int

systemPreferences.unsubscribeNotification id

Full Usage: systemPreferences.unsubscribeNotification id

Parameters:
    id : int

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Removes the subscriber with id.

id : int

systemPreferences.unsubscribeWorkspaceNotification id

Full Usage: systemPreferences.unsubscribeWorkspaceNotification id

Parameters:
    id : int

Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

Same as unsubscribeNotification, but removes the subscriber from NSWorkspace.sharedWorkspace.notificationCenter.

id : int

Type something to start searching.