From 5d7f73b263e848ea6d1542230bb63a626016e73d Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 19 Mar 2019 16:12:26 -0400 Subject: [PATCH] lock on system locked --- src/app/accounts/settings.component.ts | 10 ++++++++-- src/main/powerMonitor.main.ts | 12 ++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index 17df903c267..bc97fc79449 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 5790bbc54ff..7563f109ba5 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 {