diff --git a/src/app/accounts/settings.component.html b/src/app/accounts/settings.component.html index af7aa285..f76566c6 100644 --- a/src/app/accounts/settings.component.html +++ b/src/app/accounts/settings.component.html @@ -130,13 +130,13 @@
-
- {{'startOnLoginDesc' | i18n}} + {{'openAtLoginDesc' | i18n}}
diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index 6f670f04..111993fc 100644 --- a/src/app/accounts/settings.component.ts +++ b/src/app/accounts/settings.component.ts @@ -51,7 +51,7 @@ export class SettingsComponent implements OnInit { biometricText: string; alwaysShowDock: boolean; showAlwaysShowDock: boolean = false; - startOnLogin: boolean; + openAtLogin: boolean; enableTrayText: string; enableTrayDescText: string; @@ -157,6 +157,7 @@ export class SettingsComponent implements OnInit { this.biometricText = await this.storageService.get(ConstantsService.biometricText); this.alwaysShowDock = await this.storageService.get(ElectronConstants.alwaysShowDock); this.showAlwaysShowDock = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop; + this.openAtLogin = await this.storageService.get(ElectronConstants.openAtLogin); } async saveVaultTimeoutOptions() { @@ -307,8 +308,9 @@ export class SettingsComponent implements OnInit { await this.storageService.save(ElectronConstants.alwaysShowDock, this.alwaysShowDock); } - async saveStartOnLogin() { - this.messagingService.send(this.startOnLogin ? 'addOpenAtLogin' : 'removeOpenAtLogin'); + async saveOpenAtLogin() { + this.storageService.save(ElectronConstants.openAtLogin, this.openAtLogin); + this.messagingService.send(this.openAtLogin ? 'addOpenAtLogin' : 'removeOpenAtLogin'); } private callAnalytics(name: string, enabled: boolean) { diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 519794e7..2ec24da9 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -888,10 +888,10 @@ "startToMenuBarDesc": { "message": "When the application is first started, only show an icon in the menu bar." }, - "startOnLogin": { + "openAtLogin": { "message": "Start automatically on login" }, - "startOnLoginDesc": { + "openAtLoginDesc": { "message": "Start the Bitwarden Desktop application automatically on login." }, "alwaysShowDock": { diff --git a/src/main/messaging.main.ts b/src/main/messaging.main.ts index 208a23ff..338244fe 100644 --- a/src/main/messaging.main.ts +++ b/src/main/messaging.main.ts @@ -1,4 +1,4 @@ -import { ipcMain } from 'electron'; +import { app, ipcMain } from 'electron'; import { Main } from '../main'; @@ -15,6 +15,10 @@ export class MessagingMain { init() { this.scheduleNextSync(); + if (process.platform !== 'linux') { + const loginSettings = app.getLoginItemSettings(); + this.storageService.save(ElectronConstants.openAtLogin, loginSettings.openAtLogin); + } ipcMain.on('messagingService', async (event: any, message: any) => this.onMessage(message)); } @@ -44,9 +48,15 @@ export class MessagingMain { case 'hideToTray': this.main.trayMain.hideToTray(); break; - case 'addStartOnLogin': + case 'addOpenAtLogin': + if (process.platform !== 'linux') { + app.setLoginItemSettings({openAtLogin: true}); + } break; - case 'removeStartOnLogin': + case 'removeOpenAtLogin': + if (process.platform !== 'linux') { + app.setLoginItemSettings({openAtLogin: false}); + } break; default: break;