Skip to content

Commit

Permalink
stop listening to power events on linux (#25972)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnojima committed Oct 16, 2023
1 parent a154ede commit 06cb935
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions shared/desktop/app/node2.desktop.tsx
Expand Up @@ -367,21 +367,25 @@ const plumbEvents = () => {
Electron.nativeTheme.on('updated', () => {
mainWindowDispatch(ConfigGen.createSetSystemDarkMode({dark: Electron.nativeTheme.shouldUseDarkColors}))
})
Electron.powerMonitor.on('suspend', () => {
mainWindowDispatch(ConfigGen.createPowerMonitorEvent({event: 'suspend'}))
})
Electron.powerMonitor.on('resume', () => {
mainWindowDispatch(ConfigGen.createPowerMonitorEvent({event: 'resume'}))
})
Electron.powerMonitor.on('shutdown', () => {
mainWindowDispatch(ConfigGen.createPowerMonitorEvent({event: 'shutdown'}))
})
Electron.powerMonitor.on('lock-screen', () => {
mainWindowDispatch(ConfigGen.createPowerMonitorEvent({event: 'lock-screen'}))
})
Electron.powerMonitor.on('unlock-screen', () => {
mainWindowDispatch(ConfigGen.createPowerMonitorEvent({event: 'unlock-screen'}))
})

// this crashes on newer electron, unclear why
if (!isLinux) {
Electron.powerMonitor.on('suspend', () => {
mainWindowDispatch(ConfigGen.createPowerMonitorEvent({event: 'suspend'}))
})
Electron.powerMonitor.on('resume', () => {
mainWindowDispatch(ConfigGen.createPowerMonitorEvent({event: 'resume'}))
})
Electron.powerMonitor.on('shutdown', () => {
mainWindowDispatch(ConfigGen.createPowerMonitorEvent({event: 'shutdown'}))
})
Electron.powerMonitor.on('lock-screen', () => {
mainWindowDispatch(ConfigGen.createPowerMonitorEvent({event: 'lock-screen'}))
})
Electron.powerMonitor.on('unlock-screen', () => {
mainWindowDispatch(ConfigGen.createPowerMonitorEvent({event: 'unlock-screen'}))
})
}

Electron.ipcMain.handle('KBdispatchAction', (_: any, action: any) => {
mainWindow?.webContents.send('KBdispatchAction', action)
Expand Down

0 comments on commit 06cb935

Please sign in to comment.