From 0cd196f56c51b3fc5c8498b7c6813092856c8437 Mon Sep 17 00:00:00 2001 From: Hinton Date: Fri, 27 Nov 2020 11:34:09 +0100 Subject: [PATCH] Fix linux not creating the autostart dir if not exist --- src/main/messaging.main.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/messaging.main.ts b/src/main/messaging.main.ts index 41925bb1dd..720e6fe999 100644 --- a/src/main/messaging.main.ts +++ b/src/main/messaging.main.ts @@ -17,7 +17,9 @@ export class MessagingMain { init() { this.scheduleNextSync(); - if (process.platform !== 'linux') { + if (process.platform === 'linux') { + this.storageService.save(ElectronConstants.openAtLogin, fs.existsSync(this.linuxStartupFile())); + } else { const loginSettings = app.getLoginItemSettings(); this.storageService.save(ElectronConstants.openAtLogin, loginSettings.openAtLogin); } @@ -98,6 +100,10 @@ export class MessagingMain { StartupNotify=false Terminal=false`; + const dir = path.dirname(this.linuxStartupFile()); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } fs.writeFileSync(this.linuxStartupFile(), data); } else { app.setLoginItemSettings({openAtLogin: true}); @@ -106,9 +112,8 @@ export class MessagingMain { private removeOpenAtLogin() { if (process.platform === 'linux') { - const file = this.linuxStartupFile(); - if (fs.existsSync(file)) { - fs.unlinkSync(file); + if (fs.existsSync(this.linuxStartupFile())) { + fs.unlinkSync(this.linuxStartupFile()); } } else { app.setLoginItemSettings({openAtLogin: false});