lwe.handlers.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { ipcMain, type BrowserWindow } from 'electron'
  2. import { IpcChannels } from '@shared/ipc-channels'
  3. import { getLweStatus, detectDistro, installLweDeps, installLwe, uninstallLwe, launchLwe, stopLwe, isLweRunning } from '../services/lwe.service'
  4. import { invalidateEnvCache } from '../services/wallpaper.service'
  5. export function registerLweHandlers(win: BrowserWindow): void {
  6. ipcMain.handle(IpcChannels.LWE_STATUS, () => {
  7. return getLweStatus()
  8. })
  9. ipcMain.handle(IpcChannels.LWE_DETECT_DISTRO, () => {
  10. return detectDistro()
  11. })
  12. ipcMain.handle(IpcChannels.LWE_INSTALL_DEPS, async () => {
  13. await installLweDeps(win)
  14. return { ok: true }
  15. })
  16. ipcMain.handle(IpcChannels.LWE_INSTALL, async () => {
  17. await installLwe(win)
  18. invalidateEnvCache()
  19. return getLweStatus()
  20. })
  21. ipcMain.handle(IpcChannels.LWE_UNINSTALL, async () => {
  22. const result = await uninstallLwe()
  23. invalidateEnvCache()
  24. return result
  25. })
  26. ipcMain.handle(IpcChannels.LWE_LAUNCH, (_e, wallpaperPath: string, options?: { screenRoot?: string; fps?: number }) => {
  27. launchLwe(wallpaperPath, options)
  28. return { ok: true, running: isLweRunning() }
  29. })
  30. ipcMain.handle(IpcChannels.LWE_STOP, () => {
  31. stopLwe()
  32. return { ok: true }
  33. })
  34. }