add setting to prevent sleep on playback (#1072)

This commit is contained in:
jeffvli
2025-09-06 00:56:06 -07:00
parent 40fb5ba916
commit b00305cc86
7 changed files with 114 additions and 0 deletions
+24
View File
@@ -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