🖥️ Desktop Applications

Electron IPC Communication

Inter-process communication between Electron main and renderer processes.

Overview

The Gauzy desktop app uses Electron's IPC (Inter-Process Communication) for:

  • Timer controls from renderer → main
  • Screenshot capture from main → renderer
  • Activity data collection
  • Settings synchronization

Architecture

Diagram; its source is available below
Diagram source
graph TB
    subgraph Renderer Process
        UI[Angular UI]
    end

    subgraph Main Process
        IPC[IPC Handlers]
        Timer[Timer Service]
        Screenshot[Screenshot Service]
        DB[Local Database]
    end

    UI -->|ipcRenderer.send| IPC
    IPC -->|ipcMain.handle| Timer
    IPC --> Screenshot
    IPC --> DB
    Timer -->|BrowserWindow.send| UI

Common IPC Channels

ChannelDirectionDescription
timer:startRenderer → MainStart timer
timer:stopRenderer → MainStop timer
timer:statusMain → RendererTimer state update
screenshot:takenMain → RendererScreenshot captured
settings:updateBothSettings changed
app:minimizeRenderer → MainMinimize to tray

Renderer → Main

// In Angular component/service
const { ipcRenderer } = window.require("electron");

ipcRenderer.send("timer:start", {
  projectId: "uuid",
  taskId: "uuid",
});

ipcRenderer.on("timer:status", (event, data) => {
  // Update UI with timer state
});

Main → Renderer

// In Electron main process
ipcMain.on("timer:start", (event, data) => {
  timerService.start(data);
  // Send status back
  mainWindow.webContents.send("timer:status", { running: true });
});

Edit this page

Copyright © 2023-Present Ever Co. LTD.Docs by Sourcey