mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
Renamed folders: ./apps/desktop/src/models/nativeMessaging ./apps/desktop/src/models/nativeMessaging/encryptedMessagePayloads ./apps/desktop/src/models/nativeMessaging/encryptedMessageResponses Renamed all files Cleaned up entries in whitelist-capital-letters.txt
This commit is contained in:
committed by
GitHub
parent
175eef5376
commit
db2d8aaa7e
47
apps/desktop/src/main/power-monitor.main.ts
Normal file
47
apps/desktop/src/main/power-monitor.main.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { powerMonitor } from "electron";
|
||||
|
||||
import { isSnapStore } from "@bitwarden/electron/utils";
|
||||
|
||||
import { Main } from "../main";
|
||||
|
||||
// tslint:disable-next-line
|
||||
const IdleLockSeconds = 5 * 60; // 5 minutes
|
||||
const IdleCheckInterval = 30 * 1000; // 30 seconds
|
||||
|
||||
export class PowerMonitorMain {
|
||||
private idle = false;
|
||||
|
||||
constructor(private main: Main) {}
|
||||
|
||||
init() {
|
||||
// ref: https://github.com/electron/electron/issues/13767
|
||||
if (!isSnapStore()) {
|
||||
// System sleep
|
||||
powerMonitor.on("suspend", () => {
|
||||
this.main.messagingService.send("systemSuspended");
|
||||
});
|
||||
}
|
||||
|
||||
if (process.platform !== "linux") {
|
||||
// System locked
|
||||
powerMonitor.on("lock-screen", () => {
|
||||
this.main.messagingService.send("systemLocked");
|
||||
});
|
||||
}
|
||||
|
||||
// System idle
|
||||
global.setInterval(() => {
|
||||
const idleSeconds: number = powerMonitor.getSystemIdleTime();
|
||||
const idle = idleSeconds >= IdleLockSeconds;
|
||||
if (idle) {
|
||||
if (this.idle) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.main.messagingService.send("systemIdle");
|
||||
}
|
||||
|
||||
this.idle = idle;
|
||||
}, IdleCheckInterval);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user