44 */
55
66const { app, ipcMain, desktopCapturer, systemPreferences, shell, session } = require ( 'electron' )
7+ const { default : mri } = require ( 'mri' )
78const { spawn } = require ( 'node:child_process' )
89const fs = require ( 'node:fs' )
910const path = require ( 'node:path' )
@@ -12,6 +13,7 @@ const { loadAppConfig, getAppConfig, setAppConfig } = require('./app/AppConfig.t
1213const { appData } = require ( './app/AppData.js' )
1314const { registerAppProtocolHandler } = require ( './app/appProtocol.ts' )
1415const { verifyCertificate, promptCertificateTrust } = require ( './app/certificate.service.ts' )
16+ const { cli } = require ( './app/cli.ts' )
1517const { openChromeWebRtcInternals } = require ( './app/dev.utils.ts' )
1618const { triggerDownloadUrl } = require ( './app/downloads.ts' )
1719const { setupReleaseNotificationScheduler, registerUpdateIpcHandlers } = require ( './app/githubReleaseNotification.service.js' )
@@ -31,13 +33,7 @@ const { createTalkWindow } = require('./talk/talk.window.js')
3133const { createUpgradeWindow } = require ( './upgrade/upgrade.window.ts' )
3234const { createWelcomeWindow } = require ( './welcome/welcome.window.js' )
3335
34- /**
35- * Parse command line arguments
36- */
37- const ARGUMENTS = {
38- // Open Talk window in the background, minimized to the system tray
39- openInBackground : process . argv . includes ( '--background' ) ,
40- }
36+ const argv = mri ( process . argv . slice ( app . isPackaged ? 1 : 2 ) )
4137
4238// Electron 36 with Chromium 136 is not compatible with GNOME due to GTK3 with GTK4 mixing
4339// Workaround: force GTK3
@@ -78,6 +74,7 @@ if (require('electron-squirrel-startup')) {
7874 * Only one instance is allowed at the same time
7975 */
8076if ( ! app . requestSingleInstanceLock ( ) ) {
77+ console . log ( 'Another instance of the app is already running' )
8178 app . quit ( )
8279}
8380
@@ -140,6 +137,8 @@ app.whenReady().then(async () => {
140137 await loadAppConfig ( )
141138 await runMigrations ( )
142139
140+ await cli ( argv )
141+
143142 applyTheme ( )
144143 initLaunchAtStartupListener ( )
145144 registerAppProtocolHandler ( )
@@ -153,7 +152,7 @@ app.whenReady().then(async () => {
153152 }
154153
155154 // Open in the background if it is explicitly set, or the app was open at login on macOS
156- const openInBackground = ARGUMENTS . openInBackground || app . getLoginItemSettings ( ) . wasOpenedAtLogin
155+ const openInBackground = argv . background || app . getLoginItemSettings ( ) . wasOpenedAtLogin
157156
158157 try {
159158 await installVueDevtools ( )
0 commit comments