Skip to content

ElectronApp

Unofficial

Electron App for controlling the application lifecycle.

Import:

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

Signature:

export interface ElectronApp

Properties

PropertyTypeDescription
accessibilitySupportEnabledbooleanWhether 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.
applicationMenuElectronMenu | nullThe application menu, or null if none has been set.
badgeCountnumberThe badge count for the current app. Setting the count to 0 hides the badge. Linux and macOS only.
commandLineElectronCommandLineReads and manipulates the command line arguments that Chromium uses.
dockElectronDockPerforms actions on the app icon in the user's dock. macOS only.
isPackagedbooleanWhether the app is packaged. Can be used to distinguish development and production environments.
namestringThe current application's name, from the application's package.json file.
runningUnderARM64TranslationbooleanWhether the app is currently running under an ARM64 translator (Rosetta or Windows WOW). macOS and Windows only.
runningUnderRosettaTranslationbooleanWhether the app is currently running under the Rosetta Translator Environment. macOS only.
userAgentFallbackstringThe user agent string Electron uses as a global fallback.

Methods

MethodReturnsDescription
addListener(event, listener)thisAdds a listener for the accessibility-support-changed event.

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

Emitted when the application is activated. macOS only.
addListener(event, listener)thisAdds 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)thisAdds a listener for the before-quit event.

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

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

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

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

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

Emitted when the child process unexpectedly disappears.
addListener(event, listener)thisAdds 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)thisAdds 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)thisAdds a listener for the did-become-active event.

Emitted every time the app becomes active. macOS only.
addListener(event, listener)thisAdds 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)thisAdds a listener for the gpu-info-update event.

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

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

Emitted when webContents wants to do basic auth.
addListener(event, listener)thisAdds 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)thisAdds a listener for the open-file event.

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

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

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

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

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

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

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

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

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

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

Emitted when a new webContents is created.
addListener(event, listener)thisAdds 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)thisAdds a listener for the will-finish-launching event.

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

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

Emitted when all windows have been closed.
addRecentDocument(path)voidAdds path to the recent documents list. macOS and Windows only.
clearRecentDocuments()voidClears the recent documents list. macOS and Windows only.
configureHostResolver(options)voidConfigures host resolution (DNS and DNS-over-HTTPS). Must be called after the ready event.
disableDomainBlockingFor3DAPIs()voidDisables the per-domain blocking of 3D APIs after repeated GPU process crashes. Can only be called before the app is ready.
disableHardwareAcceleration()voidDisables hardware acceleration for the current app. Can only be called before the app is ready.
enableSandbox()voidEnables full sandbox mode on the app. Can only be called before the app is ready.
exit(exitCode?)voidExits 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?)voidFocuses 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)stringReturns 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()stringReturns the current application directory.
getBadgeCount()numberReturns the current value displayed in the counter badge. Linux and macOS only.
getCurrentActivityType()stringReturns the type of the currently running activity. macOS only.
getFileIcon(path, options?)Promise<ElectronNativeImage>Fetches a path's associated icon.
getGPUFeatureStatus()ElectronGPUFeatureStatusReturns 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()ElectronJumpListSettingsReturns the current settings of the Jump List. Windows only.
getLocale()stringReturns the current application locale, fetched using Chromium's l10n_util library.
getLocaleCountryCode()stringReturns the operating system's locale two-letter ISO 3166 country code.
getLoginItemSettings(options?)ElectronLoginItemSettingsReturns the app's login item settings. macOS and Windows only.
getName()stringReturns the current application's name, from the application's package.json file.
getPath(name)stringReturns 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()stringReturns the system's current locale as a BCP 47 language tag.
getVersion()stringReturns the version of the loaded application.
hasSingleInstanceLock()booleanReturns whether this instance of the app is currently holding the single instance lock.
hide()voidHides all application windows without minimizing them. macOS only.
importCertificate(options, callback)voidImports the certificate in pkcs12 format into the platform certificate store. Linux only.
invalidateCurrentActivity()voidInvalidates the current Handoff user activity. macOS only.
isAccessibilitySupportEnabled()booleanReturns whether Chrome's accessibility support is enabled. macOS and Windows only.
isDefaultProtocolClient(protocol, path?, args?)booleanReturns whether the current executable is the default handler for a protocol.
isEmojiPanelSupported()booleanReturns whether the current OS version allows for native emoji pickers.
isHidden()booleanReturns whether the application is currently hidden. macOS only.
isInApplicationsFolder()booleanReturns whether the application is currently running from the system's Application folder. macOS only.
isReady()booleanReturns whether Electron has finished initializing.
isSecureKeyboardEntryEnabled()booleanReturns whether Secure Keyboard Entry is enabled. macOS only.
isUnityRunning()booleanReturns whether the current desktop environment is the Unity launcher. Linux only.
moveToApplicationsFolder(options?)booleanMoves the current app to the Applications folder. If successful, the app quits and relaunches. macOS only.
on('accessibility-support-changed', listener)thisRegisters a listener for the accessibility-support-changed event.

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

Emitted when the application is activated. macOS only.
on('activity-was-continued', listener)thisRegisters 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)thisRegisters a listener for the before-quit event.

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

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

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

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

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

Emitted when the child process unexpectedly disappears.
on('continue-activity', listener)thisRegisters 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)thisRegisters 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)thisRegisters a listener for the did-become-active event.

Emitted every time the app becomes active. macOS only.
on('first-instance-ack', listener)thisRegisters 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)thisRegisters a listener for the gpu-info-update event.

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

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

Emitted when webContents wants to do basic auth.
on('new-window-for-tab', listener)thisRegisters 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)thisRegisters 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)thisRegisters a listener for the open-url event.

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

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

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

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

Emitted when the renderer process of webContents crashes or is killed.
on('second-instance', listener)thisRegisters 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)thisRegisters a listener for the select-client-certificate event.

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

Emitted when Electron has created a new session.
on('update-activity-state', listener)thisRegisters 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)thisRegisters a listener for the web-contents-created event.

Emitted when a new webContents is created.
on('will-continue-activity', listener)thisRegisters 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)thisRegisters a listener for the will-finish-launching event.

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

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

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

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

Emitted when the application is activated. macOS only.
once(event, listener)thisRegisters 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)thisRegisters a one-time listener for the before-quit event.

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

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

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

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

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

Emitted when the child process unexpectedly disappears.
once(event, listener)thisRegisters 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)thisRegisters 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)thisRegisters a one-time listener for the did-become-active event.

Emitted every time the app becomes active. macOS only.
once(event, listener)thisRegisters 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)thisRegisters a one-time listener for the gpu-info-update event.

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

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

Emitted when webContents wants to do basic auth.
once(event, listener)thisRegisters 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)thisRegisters 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)thisRegisters 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)thisRegisters a one-time listener for the quit event.

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

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

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

Emitted when the renderer process of webContents crashes or is killed.
once(event, listener)thisRegisters 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)thisRegisters a one-time listener for the select-client-certificate event.

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

Emitted when Electron has created a new session.
once(event, listener)thisRegisters 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)thisRegisters a one-time listener for the web-contents-created event.

Emitted when a new webContents is created.
once(event, listener)thisRegisters 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)thisRegisters a one-time listener for the will-finish-launching event.

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

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

Emitted when all windows have been closed.
quit()voidTries 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?)voidRelaunches the app when the current instance exits.
releaseSingleInstanceLock()voidReleases all locks that were created by requestSingleInstanceLock.
removeAsDefaultProtocolClient(protocol, path?, args?)booleanRemoves the current executable as the default handler for a protocol. macOS and Windows only.
removeListener(event, listener)thisRemoves a previously added listener for the accessibility-support-changed event.

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

Emitted when the application is activated. macOS only.
removeListener(event, listener)thisRemoves 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)thisRemoves a previously added listener for the before-quit event.

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

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

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

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

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

Emitted when the child process unexpectedly disappears.
removeListener(event, listener)thisRemoves 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)thisRemoves 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)thisRemoves a previously added listener for the did-become-active event.

Emitted every time the app becomes active. macOS only.
removeListener(event, listener)thisRemoves 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)thisRemoves a previously added listener for the gpu-info-update event.

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

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

Emitted when webContents wants to do basic auth.
removeListener(event, listener)thisRemoves 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)thisRemoves 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)thisRemoves 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)thisRemoves a previously added listener for the quit event.

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

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

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

Emitted when the renderer process of webContents crashes or is killed.
removeListener(event, listener)thisRemoves 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)thisRemoves a previously added listener for the select-client-certificate event.

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

Emitted when Electron has created a new session.
removeListener(event, listener)thisRemoves 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)thisRemoves a previously added listener for the web-contents-created event.

Emitted when a new webContents is created.
removeListener(event, listener)thisRemoves 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)thisRemoves a previously added listener for the will-finish-launching event.

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

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

Emitted when all windows have been closed.
requestSingleInstanceLock(additionalData?)booleanRequests the single instance lock. Returns whether this instance obtained the lock and should continue loading.
resignCurrentActivity()voidMarks the current Handoff user activity as inactive without invalidating it. macOS only.
setAboutPanelOptions(options)voidSets the about panel options.
setAccessibilitySupportEnabled(enabled)voidManually enables or disables Chrome's accessibility support. Must be called after the ready event. macOS and Windows only.
setActivationPolicy(policy)voidSets the activation policy for the app. macOS only.
setAppLogsPath(path?)voidSets or creates a directory for the app's logs.
setAppUserModelId(id)voidChanges the Application User Model ID to id. Windows only.
setAsDefaultProtocolClient(protocol, path?, args?)booleanSets the current executable as the default handler for a protocol.
setBadgeCount(count?)booleanSets the counter badge for the current app. Setting the count to 0 hides the badge. Linux and macOS only.
setJumpList(categories)voidSets or removes a custom Jump List for the application. Windows only.
setLoginItemSettings(settings)voidSets the app's login item settings. macOS and Windows only.
setName(name)voidOverrides the current application's name.
setPath(name, path)voidOverrides the path to a special directory or file associated with name.
setSecureKeyboardEntryEnabled(enabled)voidSets whether Secure Keyboard Entry is enabled in the application. macOS only.
setUserActivity(type, userInfo, webpageURL?)voidCreates an NSUserActivity and sets it as the current activity. macOS only.
setUserTasks(tasks)booleanAdds tasks to the Tasks category of the Jump List. Windows only.
show()voidShows application windows after they were hidden. Does not automatically focus them. macOS only.
showAboutPanel()voidShows the app's about panel options.
showEmojiPanel()voidShows the platform's native emoji picker. macOS and Windows only.
startAccessingSecurityScopedResource(bookmarkData)() => voidStarts accessing a security scoped resource. Must be balanced by calling the returned function once finished. macOS (MAS) only.
updateCurrentActivity(type, userInfo)voidUpdates 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: