@@ -100,7 +100,6 @@ const isWindows = platform() === 'win32'
100
100
let mainWindow : BrowserWindow = null
101
101
102
102
async function createWindow ( ) : Promise < BrowserWindow > {
103
- const { exitToTray, startInTray } = await GlobalConfig . get ( ) . getSettings ( )
104
103
configStore . set ( 'userHome' , userHome )
105
104
106
105
let windowProps : Electron . Rectangle = {
@@ -139,7 +138,7 @@ async function createWindow(): Promise<BrowserWindow> {
139
138
...windowProps ,
140
139
minHeight : 345 ,
141
140
minWidth : 600 ,
142
- show : ! ( exitToTray && startInTray ) ,
141
+ show : false ,
143
142
webPreferences : {
144
143
webviewTag : true ,
145
144
contextIsolation : false ,
@@ -280,17 +279,7 @@ if (!gotTheLock) {
280
279
mainWindow . show ( )
281
280
}
282
281
283
- // Figure out which argv element is our protocol
284
- let heroicProtocolString = ''
285
- argv . forEach ( ( value ) => {
286
- if ( value . startsWith ( 'heroic://' ) ) {
287
- heroicProtocolString = value
288
- }
289
- } )
290
-
291
- if ( heroicProtocolString ) {
292
- handleProtocol ( mainWindow , heroicProtocolString )
293
- }
282
+ handleProtocol ( mainWindow , argv )
294
283
} )
295
284
app . whenReady ( ) . then ( async ( ) => {
296
285
const systemInfo = await getSystemInfo ( )
@@ -364,7 +353,7 @@ if (!gotTheLock) {
364
353
await createWindow ( )
365
354
366
355
protocol . registerStringProtocol ( 'heroic' , ( request , callback ) => {
367
- handleProtocol ( mainWindow , request . url )
356
+ handleProtocol ( mainWindow , [ request . url ] )
368
357
callback ( 'Operation initiated.' )
369
358
} )
370
359
if ( ! app . isDefaultProtocolClient ( 'heroic' ) ) {
@@ -376,11 +365,15 @@ if (!gotTheLock) {
376
365
} else {
377
366
logWarning ( 'Protocol already registered.' , LogPrefix . Backend )
378
367
}
379
- if ( process . argv [ 1 ] ) {
380
- const url = process . argv [ 1 ]
381
- handleProtocol ( mainWindow , url )
368
+
369
+ const { startInTray } = await GlobalConfig . get ( ) . getSettings ( )
370
+ const headless = process . argv . includes ( '--no-gui' ) || startInTray
371
+ if ( ! headless ) {
372
+ mainWindow . show ( )
382
373
}
383
374
375
+ handleProtocol ( mainWindow , process . argv )
376
+
384
377
// set initial zoom level after a moment, if set in sync the value stays as 1
385
378
setTimeout ( ( ) => {
386
379
const zoomFactor =
@@ -512,7 +505,7 @@ app.on('window-all-closed', () => {
512
505
513
506
app . on ( 'open-url' , ( event , url ) => {
514
507
event . preventDefault ( )
515
- handleProtocol ( mainWindow , url )
508
+ handleProtocol ( mainWindow , [ url ] )
516
509
} )
517
510
518
511
ipcMain . on ( 'openFolder' , async ( event , folder ) => openUrlOrFile ( folder ) )
@@ -895,6 +888,11 @@ Game Settings: ${JSON.stringify(gameSettings, null, '\t')}
895
888
runner,
896
889
status : 'done'
897
890
} )
891
+
892
+ // Exit if we've been launched without UI
893
+ if ( process . argv . includes ( '--no-gui' ) ) {
894
+ app . exit ( )
895
+ }
898
896
} )
899
897
}
900
898
)
0 commit comments