mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-15 13:00:25 +02:00
add setting to prevent sleep on playback (#1072)
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
nativeImage,
|
||||
nativeTheme,
|
||||
net,
|
||||
powerSaveBlocker,
|
||||
protocol,
|
||||
Rectangle,
|
||||
screen,
|
||||
@@ -66,6 +67,7 @@ let mainWindow: BrowserWindow | null = null;
|
||||
let tray: null | Tray = null;
|
||||
let exitFromTray = false;
|
||||
let forceQuit = false;
|
||||
let powerSaveBlockerId: null | number = null;
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
import('source-map-support').then((sourceMapSupport) => {
|
||||
@@ -616,6 +618,28 @@ ipcMain.on(
|
||||
},
|
||||
);
|
||||
|
||||
ipcMain.handle('power-save-blocker-start', () => {
|
||||
if (powerSaveBlockerId !== null) {
|
||||
return powerSaveBlockerId;
|
||||
}
|
||||
|
||||
powerSaveBlockerId = powerSaveBlocker.start('prevent-display-sleep');
|
||||
return powerSaveBlockerId;
|
||||
});
|
||||
|
||||
ipcMain.handle('power-save-blocker-stop', () => {
|
||||
if (powerSaveBlockerId !== null) {
|
||||
const stopped = powerSaveBlocker.stop(powerSaveBlockerId);
|
||||
powerSaveBlockerId = null;
|
||||
return stopped;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
ipcMain.handle('power-save-blocker-is-started', () => {
|
||||
return powerSaveBlockerId !== null && powerSaveBlocker.isStarted(powerSaveBlockerId);
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
globalShortcut.unregisterAll();
|
||||
// Respect the OSX convention of having the application in memory even
|
||||
|
||||
Reference in New Issue
Block a user