Skip to content

ElectronApp

Unofficial

Electron App for controlling the application lifecycle.

Import:

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

Signature:

export interface ElectronApp

Properties

Property Type Description
accessibilitySupportEnabled boolean Whether Chrome's accessibility support is enabled. Setting this to true manually enables accessibility support. Must be set after the ready event is emitted. macOS and Windows only.
applicationMenu ElectronMenu | null The application menu, or null if none has been set.
badgeCount number The badge count for the current app. Setting the count to 0 hides the badge. Linux and macOS only.
commandLine ElectronCommandLine Reads and manipulates the command line arguments that Chromium uses.
dock ElectronDock Performs actions on the app icon in the user's dock. macOS only.
isPackaged boolean Whether the app is packaged. Can be used to distinguish development and production environments.
name string The current application's name, from the application's package.json file.
runningUnderARM64Translation boolean Whether the app is currently running under an ARM64 translator (Rosetta or Windows WOW). macOS and Windows only.
runningUnderRosettaTranslation boolean Whether the app is currently running under the Rosetta Translator Environment. macOS only.
userAgentFallback string The user agent string Electron uses as a global fallback.

Methods

Method Returns Description
addListener(event, listener) this Adds a listener for the accessibility-support-changed event.

Emitted when Chrome's accessibility support changes. macOS and Windows only.
addListener(event, listener) this Adds a listener for the activate event.

Emitted when the application is activated. macOS only.
addListener(event, listener) this Adds a listener for the activity-was-continued event.

Emitted during Handoff after an activity from this device was successfully resumed on another one. macOS only.
addListener(event, listener) this Adds a listener for the before-quit event.

Emitted before the application starts closing its windows.
addListener(event, listener) this Adds a listener for the browser-window-blur event.

Emitted when a browserWindow gets blurred.
addListener(event, listener) this Adds a listener for the browser-window-created event.

Emitted when a new browserWindow is created.
addListener(event, listener) this Adds a listener for the browser-window-focus event.

Emitted when a browserWindow gets focused.
addListener(event, listener) this Adds a listener for the certificate-error event.

Emitted when failed to verify the certificate for a URL.
addListener(event, listener) this Adds a listener for the child-process-gone event.

Emitted when the child process unexpectedly disappears.
addListener(event, listener) this Adds a listener for the continue-activity event.

Emitted during Handoff when an activity from a different device wants to be resumed. macOS only.
addListener(event, listener) this Adds a listener for the continue-activity-error event.

Emitted during Handoff when an activity from a different device fails to be resumed. macOS only.
addListener(event, listener) this Adds a listener for the did-become-active event.

Emitted every time the app becomes active. macOS only.
addListener(event, listener) this Adds a listener for the first-instance-ack event.

Emitted in the second instance during requestSingleInstanceLock when the first instance calls the ackCallback.
addListener(event, listener) this Adds a listener for the gpu-info-update event.

Emitted whenever there is a GPU info update.
addListener(event, listener) this Adds a listener for the gpu-process-crashed event.

Emitted when the GPU process crashes or is killed.
addListener(event, listener) this Adds a listener for the login event.

Emitted when webContents wants to do basic auth.
addListener(event, listener) this Adds a listener for the new-window-for-tab event.

Emitted when the user clicks the native macOS new tab button. macOS only.
addListener(event, listener) this Adds a listener for the open-file event.

Emitted when the user wants to open a file with the application. macOS only.
addListener(event, listener) this Adds a listener for the open-url event.

Emitted when the user wants to open a URL with the application. macOS only.
addListener(event, listener) this Adds a listener for the quit event.

Emitted when the application is quitting.
addListener(event, listener) this Adds a listener for the ready event.

Emitted once, when Electron has finished initializing.
addListener(event, listener) this Adds a listener for the render-process-gone event.

Emitted when the renderer process unexpectedly disappears.
addListener(event, listener) this Adds a listener for the renderer-process-crashed event.

Emitted when the renderer process of webContents crashes or is killed.
addListener(event, listener) this Adds a listener for the second-instance event.

Emitted inside the primary instance when a second instance is executed and calls requestSingleInstanceLock.
addListener(event, listener) this Adds a listener for the select-client-certificate event.

Emitted when a client certificate is requested.
addListener(event, listener) this Adds a listener for the session-created event.

Emitted when Electron has created a new session.
addListener(event, listener) this Adds a listener for the update-activity-state event.

Emitted when Handoff is about to be resumed on another device. macOS only.
addListener(event, listener) this Adds a listener for the web-contents-created event.

Emitted when a new webContents is created.
addListener(event, listener) this Adds a listener for the will-continue-activity event.

Emitted during Handoff before an activity from a different device wants to be resumed. macOS only.
addListener(event, listener) this Adds a listener for the will-finish-launching event.

Emitted when the application has finished basic startup.
addListener(event, listener) this Adds a listener for the will-quit event.

Emitted when all windows have been closed and the application will quit.
addListener(event, listener) this Adds a listener for the window-all-closed event.

Emitted when all windows have been closed.
addRecentDocument(path) void Adds path to the recent documents list. macOS and Windows only.
clearRecentDocuments() void Clears the recent documents list. macOS and Windows only.
configureHostResolver(options) void Configures host resolution (DNS and DNS-over-HTTPS). Must be called after the ready event.
disableDomainBlockingFor3DAPIs() void Disables the per-domain blocking of 3D APIs after repeated GPU process crashes. Can only be called before the app is ready.
disableHardwareAcceleration() void Disables hardware acceleration for the current app. Can only be called before the app is ready.
enableSandbox() void Enables full sandbox mode on the app. Can only be called before the app is ready.
exit(exitCode?) void Exits immediately with exitCode. All windows are closed immediately without asking the user, and the before-quit and will-quit events are not emitted.
focus(options?) void Focuses the app. On Linux, focuses the first visible window; on macOS, makes the app active; on Windows, focuses the app's first window.
getApplicationInfoForProtocol(url) Promise<ElectronApplicationInfoForProtocolReturnValue> Returns the application name, icon and path of the default handler for the protocol of a URL. macOS and Windows only.
getApplicationNameForProtocol(url) string Returns the application name of the default handler for the protocol of a URL.
getAppMetrics() ElectronProcessMetric[] Returns memory and CPU usage statistics of all the processes associated with the app.
getAppPath() string Returns the current application directory.
getBadgeCount() number Returns the current value displayed in the counter badge. Linux and macOS only.
getCurrentActivityType() string Returns the type of the currently running activity. macOS only.
getFileIcon(path, options?) Promise<ElectronNativeImage> Fetches a path's associated icon.
getGPUFeatureStatus() ElectronGPUFeatureStatus Returns the Graphics Feature Status from chrome://gpu/. Only usable after the gpu-info-update event is emitted.
getGPUInfo(infoType) Promise<unknown> Returns GPU information as in Chromium's GPUInfo object.
getJumpListSettings() ElectronJumpListSettings Returns the current settings of the Jump List. Windows only.
getLocale() string Returns the current application locale, fetched using Chromium's l10n_util library.
getLocaleCountryCode() string Returns the operating system's locale two-letter ISO 3166 country code.
getLoginItemSettings(options?) ElectronLoginItemSettings Returns the app's login item settings. macOS and Windows only.
getName() string Returns the current application's name, from the application's package.json file.
getPath(name) string Returns a path to a special directory or file associated with name.
getPreferredSystemLanguages() string[] Returns the user's preferred system languages, most preferred first, as BCP 47 language tags.
getSystemLocale() string Returns the system's current locale as a BCP 47 language tag.
getVersion() string Returns the version of the loaded application.
hasSingleInstanceLock() boolean Returns whether this instance of the app is currently holding the single instance lock.
hide() void Hides all application windows without minimizing them. macOS only.
importCertificate(options, callback) void Imports the certificate in pkcs12 format into the platform certificate store. Linux only.
invalidateCurrentActivity() void Invalidates the current Handoff user activity. macOS only.
isAccessibilitySupportEnabled() boolean Returns whether Chrome's accessibility support is enabled. macOS and Windows only.
isDefaultProtocolClient(protocol, path?, args?) boolean Returns whether the current executable is the default handler for a protocol.
isEmojiPanelSupported() boolean Returns whether the current OS version allows for native emoji pickers.
isHidden() boolean Returns whether the application is currently hidden. macOS only.
isInApplicationsFolder() boolean Returns whether the application is currently running from the system's Application folder. macOS only.
isReady() boolean Returns whether Electron has finished initializing.
isSecureKeyboardEntryEnabled() boolean Returns whether Secure Keyboard Entry is enabled. macOS only.
isUnityRunning() boolean Returns whether the current desktop environment is the Unity launcher. Linux only.
moveToApplicationsFolder(options?) boolean Moves the current app to the Applications folder. If successful, the app quits and relaunches. macOS only.
on('accessibility-support-changed', listener) this Registers a listener for the accessibility-support-changed event.

Emitted when Chrome's accessibility support changes. macOS and Windows only.
on('activate', listener) this Registers a listener for the activate event.

Emitted when the application is activated. macOS only.
on('activity-was-continued', listener) this Registers a listener for the activity-was-continued event.

Emitted during Handoff after an activity from this device was successfully resumed on another one. macOS only.
on('before-quit', listener) this Registers a listener for the before-quit event.

Emitted before the application starts closing its windows.
on('browser-window-blur', listener) this Registers a listener for the browser-window-blur event.

Emitted when a browserWindow gets blurred.
on('browser-window-created', listener) this Registers a listener for the browser-window-created event.

Emitted when a new browserWindow is created.
on('browser-window-focus', listener) this Registers a listener for the browser-window-focus event.

Emitted when a browserWindow gets focused.
on('certificate-error', listener) this Registers a listener for the certificate-error event.

Emitted when failed to verify the certificate for a URL.
on('child-process-gone', listener) this Registers a listener for the child-process-gone event.

Emitted when the child process unexpectedly disappears.
on('continue-activity', listener) this Registers a listener for the continue-activity event.

Emitted during Handoff when an activity from a different device wants to be resumed. macOS only.
on('continue-activity-error', listener) this Registers a listener for the continue-activity-error event.

Emitted during Handoff when an activity from a different device fails to be resumed. macOS only.
on('did-become-active', listener) this Registers a listener for the did-become-active event.

Emitted every time the app becomes active. macOS only.
on('first-instance-ack', listener) this Registers a listener for the first-instance-ack event.

Emitted in the second instance during requestSingleInstanceLock when the first instance calls the ackCallback.
on('gpu-info-update', listener) this Registers a listener for the gpu-info-update event.

Emitted whenever there is a GPU info update.
on('gpu-process-crashed', listener) this Registers a listener for the gpu-process-crashed event.

Emitted when the GPU process crashes or is killed.
on('login', listener) this Registers a listener for the login event.

Emitted when webContents wants to do basic auth.
on('new-window-for-tab', listener) this Registers a listener for the new-window-for-tab event.

Emitted when the user clicks the native macOS new tab button. macOS only.
on('open-file', listener) this Registers a listener for the open-file event.

Emitted when the user wants to open a file with the application. macOS only.
on('open-url', listener) this Registers a listener for the open-url event.

Emitted when the user wants to open a URL with the application. macOS only.
on('quit', listener) this Registers a listener for the quit event.

Emitted when the application is quitting.
on('ready', listener) this Registers a listener for the ready event.

Emitted once, when Electron has finished initializing.
on('render-process-gone', listener) this Registers a listener for the render-process-gone event.

Emitted when the renderer process unexpectedly disappears.
on('renderer-process-crashed', listener) this Registers a listener for the renderer-process-crashed event.

Emitted when the renderer process of webContents crashes or is killed.
on('second-instance', listener) this Registers a listener for the second-instance event.

Emitted inside the primary instance when a second instance is executed and calls requestSingleInstanceLock.
on('select-client-certificate', listener) this Registers a listener for the select-client-certificate event.

Emitted when a client certificate is requested.
on('session-created', listener) this Registers a listener for the session-created event.

Emitted when Electron has created a new session.
on('update-activity-state', listener) this Registers a listener for the update-activity-state event.

Emitted when Handoff is about to be resumed on another device. macOS only.
on('web-contents-created', listener) this Registers a listener for the web-contents-created event.

Emitted when a new webContents is created.
on('will-continue-activity', listener) this Registers a listener for the will-continue-activity event.

Emitted during Handoff before an activity from a different device wants to be resumed. macOS only.
on('will-finish-launching', listener) this Registers a listener for the will-finish-launching event.

Emitted when the application has finished basic startup.
on('will-quit', listener) this Registers a listener for the will-quit event.

Emitted when all windows have been closed and the application will quit.
on('window-all-closed', listener) this Registers a listener for the window-all-closed event.

Emitted when all windows have been closed.
once(event, listener) this Registers a one-time listener for the accessibility-support-changed event.

Emitted when Chrome's accessibility support changes. macOS and Windows only.
once(event, listener) this Registers a one-time listener for the activate event.

Emitted when the application is activated. macOS only.
once(event, listener) this Registers a one-time listener for the activity-was-continued event.

Emitted during Handoff after an activity from this device was successfully resumed on another one. macOS only.
once(event, listener) this Registers a one-time listener for the before-quit event.

Emitted before the application starts closing its windows.
once(event, listener) this Registers a one-time listener for the browser-window-blur event.

Emitted when a browserWindow gets blurred.
once(event, listener) this Registers a one-time listener for the browser-window-created event.

Emitted when a new browserWindow is created.
once(event, listener) this Registers a one-time listener for the browser-window-focus event.

Emitted when a browserWindow gets focused.
once(event, listener) this Registers a one-time listener for the certificate-error event.

Emitted when failed to verify the certificate for a URL.
once(event, listener) this Registers a one-time listener for the child-process-gone event.

Emitted when the child process unexpectedly disappears.
once(event, listener) this Registers a one-time listener for the continue-activity event.

Emitted during Handoff when an activity from a different device wants to be resumed. macOS only.
once(event, listener) this Registers a one-time listener for the continue-activity-error event.

Emitted during Handoff when an activity from a different device fails to be resumed. macOS only.
once(event, listener) this Registers a one-time listener for the did-become-active event.

Emitted every time the app becomes active. macOS only.
once(event, listener) this Registers a one-time listener for the first-instance-ack event.

Emitted in the second instance during requestSingleInstanceLock when the first instance calls the ackCallback.
once(event, listener) this Registers a one-time listener for the gpu-info-update event.

Emitted whenever there is a GPU info update.
once(event, listener) this Registers a one-time listener for the gpu-process-crashed event.

Emitted when the GPU process crashes or is killed.
once(event, listener) this Registers a one-time listener for the login event.

Emitted when webContents wants to do basic auth.
once(event, listener) this Registers a one-time listener for the new-window-for-tab event.

Emitted when the user clicks the native macOS new tab button. macOS only.
once(event, listener) this Registers a one-time listener for the open-file event.

Emitted when the user wants to open a file with the application. macOS only.
once(event, listener) this Registers a one-time listener for the open-url event.

Emitted when the user wants to open a URL with the application. macOS only.
once(event, listener) this Registers a one-time listener for the quit event.

Emitted when the application is quitting.
once(event, listener) this Registers a one-time listener for the ready event.

Emitted once, when Electron has finished initializing.
once(event, listener) this Registers a one-time listener for the render-process-gone event.

Emitted when the renderer process unexpectedly disappears.
once(event, listener) this Registers a one-time listener for the renderer-process-crashed event.

Emitted when the renderer process of webContents crashes or is killed.
once(event, listener) this Registers a one-time listener for the second-instance event.

Emitted inside the primary instance when a second instance is executed and calls requestSingleInstanceLock.
once(event, listener) this Registers a one-time listener for the select-client-certificate event.

Emitted when a client certificate is requested.
once(event, listener) this Registers a one-time listener for the session-created event.

Emitted when Electron has created a new session.
once(event, listener) this Registers a one-time listener for the update-activity-state event.

Emitted when Handoff is about to be resumed on another device. macOS only.
once(event, listener) this Registers a one-time listener for the web-contents-created event.

Emitted when a new webContents is created.
once(event, listener) this Registers a one-time listener for the will-continue-activity event.

Emitted during Handoff before an activity from a different device wants to be resumed. macOS only.
once(event, listener) this Registers a one-time listener for the will-finish-launching event.

Emitted when the application has finished basic startup.
once(event, listener) this Registers a one-time listener for the will-quit event.

Emitted when all windows have been closed and the application will quit.
once(event, listener) this Registers a one-time listener for the window-all-closed event.

Emitted when all windows have been closed.
quit() void Tries to close all windows. The before-quit event is emitted first; if all windows are successfully closed, the will-quit event is emitted and by default the application terminates.
relaunch(options?) void Relaunches the app when the current instance exits.
releaseSingleInstanceLock() void Releases all locks that were created by requestSingleInstanceLock.
removeAsDefaultProtocolClient(protocol, path?, args?) boolean Removes the current executable as the default handler for a protocol. macOS and Windows only.
removeListener(event, listener) this Removes a previously added listener for the accessibility-support-changed event.

Emitted when Chrome's accessibility support changes. macOS and Windows only.
removeListener(event, listener) this Removes a previously added listener for the activate event.

Emitted when the application is activated. macOS only.
removeListener(event, listener) this Removes a previously added listener for the activity-was-continued event.

Emitted during Handoff after an activity from this device was successfully resumed on another one. macOS only.
removeListener(event, listener) this Removes a previously added listener for the before-quit event.

Emitted before the application starts closing its windows.
removeListener(event, listener) this Removes a previously added listener for the browser-window-blur event.

Emitted when a browserWindow gets blurred.
removeListener(event, listener) this Removes a previously added listener for the browser-window-created event.

Emitted when a new browserWindow is created.
removeListener(event, listener) this Removes a previously added listener for the browser-window-focus event.

Emitted when a browserWindow gets focused.
removeListener(event, listener) this Removes a previously added listener for the certificate-error event.

Emitted when failed to verify the certificate for a URL.
removeListener(event, listener) this Removes a previously added listener for the child-process-gone event.

Emitted when the child process unexpectedly disappears.
removeListener(event, listener) this Removes a previously added listener for the continue-activity event.

Emitted during Handoff when an activity from a different device wants to be resumed. macOS only.
removeListener(event, listener) this Removes a previously added listener for the continue-activity-error event.

Emitted during Handoff when an activity from a different device fails to be resumed. macOS only.
removeListener(event, listener) this Removes a previously added listener for the did-become-active event.

Emitted every time the app becomes active. macOS only.
removeListener(event, listener) this Removes a previously added listener for the first-instance-ack event.

Emitted in the second instance during requestSingleInstanceLock when the first instance calls the ackCallback.
removeListener(event, listener) this Removes a previously added listener for the gpu-info-update event.

Emitted whenever there is a GPU info update.
removeListener(event, listener) this Removes a previously added listener for the gpu-process-crashed event.

Emitted when the GPU process crashes or is killed.
removeListener(event, listener) this Removes a previously added listener for the login event.

Emitted when webContents wants to do basic auth.
removeListener(event, listener) this Removes a previously added listener for the new-window-for-tab event.

Emitted when the user clicks the native macOS new tab button. macOS only.
removeListener(event, listener) this Removes a previously added listener for the open-file event.

Emitted when the user wants to open a file with the application. macOS only.
removeListener(event, listener) this Removes a previously added listener for the open-url event.

Emitted when the user wants to open a URL with the application. macOS only.
removeListener(event, listener) this Removes a previously added listener for the quit event.

Emitted when the application is quitting.
removeListener(event, listener) this Removes a previously added listener for the ready event.

Emitted once, when Electron has finished initializing.
removeListener(event, listener) this Removes a previously added listener for the render-process-gone event.

Emitted when the renderer process unexpectedly disappears.
removeListener(event, listener) this Removes a previously added listener for the renderer-process-crashed event.

Emitted when the renderer process of webContents crashes or is killed.
removeListener(event, listener) this Removes a previously added listener for the second-instance event.

Emitted inside the primary instance when a second instance is executed and calls requestSingleInstanceLock.
removeListener(event, listener) this Removes a previously added listener for the select-client-certificate event.

Emitted when a client certificate is requested.
removeListener(event, listener) this Removes a previously added listener for the session-created event.

Emitted when Electron has created a new session.
removeListener(event, listener) this Removes a previously added listener for the update-activity-state event.

Emitted when Handoff is about to be resumed on another device. macOS only.
removeListener(event, listener) this Removes a previously added listener for the web-contents-created event.

Emitted when a new webContents is created.
removeListener(event, listener) this Removes a previously added listener for the will-continue-activity event.

Emitted during Handoff before an activity from a different device wants to be resumed. macOS only.
removeListener(event, listener) this Removes a previously added listener for the will-finish-launching event.

Emitted when the application has finished basic startup.
removeListener(event, listener) this Removes a previously added listener for the will-quit event.

Emitted when all windows have been closed and the application will quit.
removeListener(event, listener) this Removes a previously added listener for the window-all-closed event.

Emitted when all windows have been closed.
requestSingleInstanceLock(additionalData?) boolean Requests the single instance lock. Returns whether this instance obtained the lock and should continue loading.
resignCurrentActivity() void Marks the current Handoff user activity as inactive without invalidating it. macOS only.
setAboutPanelOptions(options) void Sets the about panel options.
setAccessibilitySupportEnabled(enabled) void Manually enables or disables Chrome's accessibility support. Must be called after the ready event. macOS and Windows only.
setActivationPolicy(policy) void Sets the activation policy for the app. macOS only.
setAppLogsPath(path?) void Sets or creates a directory for the app's logs.
setAppUserModelId(id) void Changes the Application User Model ID to id. Windows only.
setAsDefaultProtocolClient(protocol, path?, args?) boolean Sets the current executable as the default handler for a protocol.
setBadgeCount(count?) boolean Sets the counter badge for the current app. Setting the count to 0 hides the badge. Linux and macOS only.
setJumpList(categories) void Sets or removes a custom Jump List for the application. Windows only.
setLoginItemSettings(settings) void Sets the app's login item settings. macOS and Windows only.
setName(name) void Overrides the current application's name.
setPath(name, path) void Overrides the path to a special directory or file associated with name.
setSecureKeyboardEntryEnabled(enabled) void Sets whether Secure Keyboard Entry is enabled in the application. macOS only.
setUserActivity(type, userInfo, webpageURL?) void Creates an NSUserActivity and sets it as the current activity. macOS only.
setUserTasks(tasks) boolean Adds tasks to the Tasks category of the Jump List. Windows only.
show() void Shows application windows after they were hidden. Does not automatically focus them. macOS only.
showAboutPanel() void Shows the app's about panel options.
showEmojiPanel() void Shows the platform's native emoji picker. macOS and Windows only.
startAccessingSecurityScopedResource(bookmarkData) () => void Starts accessing a security scoped resource. Must be balanced by calling the returned function once finished. macOS (MAS) only.
updateCurrentActivity(type, userInfo) void Updates the current activity if its type matches type, merging the entries from userInfo. macOS only.
whenReady() Promise<void> Returns a promise fulfilled when Electron is initialized.

Links to this page: