diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index 17df903c..bc97fc79 100644 --- a/src/app/accounts/settings.component.ts +++ b/src/app/accounts/settings.component.ts @@ -60,10 +60,16 @@ export class SettingsComponent implements OnInit { { name: i18nService.t('fourHours'), value: 240 }, { name: i18nService.t('onIdle'), value: -4 }, { name: i18nService.t('onSleep'), value: -3 }, - // { name: i18nService.t('onLocked'), value: -2 }, + ]; + + if (this.platformUtilsService.getDevice() !== DeviceType.LinuxDesktop) { + this.lockOptions.push({ name: i18nService.t('onLocked'), value: -2 }); + } + + this.lockOptions = this.lockOptions.concat([ { name: i18nService.t('onRestart'), value: -1 }, { name: i18nService.t('never'), value: null }, - ]; + ]); const localeOptions: any[] = []; i18nService.supportedTranslationLocales.forEach((locale) => { diff --git a/src/main/powerMonitor.main.ts b/src/main/powerMonitor.main.ts index 5790bbc5..7563f109 100644 --- a/src/main/powerMonitor.main.ts +++ b/src/main/powerMonitor.main.ts @@ -28,6 +28,16 @@ export class PowerMonitorMain { }); } + if (process.platform !== 'linux') { + // System locked + powerMonitor.on('lock-screen', async () => { + const lockOption = await this.getLockOption(); + if (lockOption === -2) { + this.main.messagingService.send('lockVault'); + } + }); + } + // System idle global.setInterval(async () => { const idleSeconds: number = desktopIdle.getIdleTime(); @@ -45,8 +55,6 @@ export class PowerMonitorMain { this.idle = idle; }, IdleCheckInterval); - - // TODO: System locked } private getLockOption(): Promise {