Introducing a new way to review your PRs.

Read the announcement

aprilnea / openlogi

⚡️A native, local-first alternative to Logitech Options+, written in Rust 🦀 — remap buttons, DPI, and SmartShift over HID++. No account, no telemetry.

View on GitHub

25 documents · Updated Nov 23, 2026

docs / application-composition

Application composition and process roles

OpenLogi is a local-first desktop companion for Logitech HID++ devices. It divides product work across a desktop application, a long-lived agent, a command-line interface, and small helper processes. Local IPC connects these processes while the agent keeps ownership of Logitech device access, system input, and the shared state that clients observe.

Process roles

Desktop application process

The desktop application is the user-facing control surface. It opens the main device workspace and auxiliary windows, reads the agent's snapshots, and sends agent-owned changes to the agent. Logitech HID++ access and system input remain agent responsibilities. Camera UVC controls are a separate desktop-owned camera path because they affect the host camera used by other applications. See the Desktop application page for the window and UI model, and the cross-device flow page for Flow coordination.

The Home screen presents the known device set. A device workspace then shows only the sections that match the device's measured or known capabilities. These sections cover bindings and workflows, pointer behavior, keyboard and standalone lighting, camera controls, host switching, audio, and device links. The desktop combines agent state with its own camera scan and saved device identity to build this view.

The desktop separates live state from saved identity. It can keep an offline device visible while removing its writable route. It also shows neutral connecting and reconnecting states instead of treating missing data as a denied permission or an empty inventory. User actions such as pairing, settings changes, and Flow setup start in the desktop, while the agent or another owner performs the work.

The desktop also accepts openlogi:// links from the agent tray and other callers. A link can open a window or a device page during a cold launch or while the app is already running. If the device list is not complete, the desktop waits for the matching snapshot before opening the named page.

References: crates/…/app.rs• L47-121 crates/…/app.rs• L609-799 crates/…/detail.rs• L61-189 crates/…/status.rs• L66-155 crates/…/deeplink.rs• L22-129 crates/…/deeplink.rs• L131-207 crates/…/widgets.rs• L46-115 crates/…/controls.rs• L1-11 crates/…/controls.rs• L722-762 crates/…/function_row.rs• L159-230 crates/…/standalone.rs• L20-28 crates/…/keyboard_rgb.rs• L44-72 crates/…/host_switch.rs• L18-108 crates/…/action_ring.rs• L10-107 crates/…/dpi.rs• L130-213

Background agent process

The background agent is the long-lived owner of Logitech device access and system input behavior. Its headless core coordinates inventory, device capture, configuration, Flow, the OS input hook, and action execution without linking the desktop UI. It publishes these facts as one observable state for IPC clients. See the Background agent page for the agent runtime.

The agent starts in stages. It can bind IPC and answer client demand before it opens devices or asks for permissions. It then decides whether the process is wanted, arms platform services, starts inventory and input watchers, and enters its running state. This lets a login-started macOS agent remain dormant until the desktop asks for it, while Windows and Linux starts proceed as requested.

The agent owns the system tray where the platform supports one. The tray is a view over the agent snapshot and configuration. It can show attention states, devices, the current application, Flow peers, and links into desktop windows. Device controls in the tray use the same agent-owned settings path as desktop requests, so the tray does not become a second device owner.

The agent also owns replacement and shutdown. Before it exits or hands over to a new binary, it drains device sessions, ends temporary helper work, releases input capture, and then terminates. A process-wide instance guard prevents two agents from competing for the same device channels, input hook, or IPC endpoint.

The repository also provides a hardware-free mock agent for desktop development. It serves the real agent IPC contract with scripted inventory, settings, and Flow pairing states, so the desktop can exercise device pages, state changes, and cross-device pairing without opening hardware. Mock pairing follows the same broad user stages as the real flow: discovery, connection, shared-code confirmation, peer confirmation, and saved peer state.

References: crates/…/main.rs• L56-174 crates/…/startup.rs• L31-126 crates/…/lifecycle.rs• L60-88 crates/…/lifecycle.rs• L90-277 crates/…/lifecycle.rs• L314-395 crates/…/server.rs• L52-161 crates/…/settings.rs• L12-31 crates/…/tray.rs• L1-35 crates/…/tray.rs• L683-745 crates/…/tray_model.rs• L36-90 crates/…/tray_model.rs• L742-802 crates/…/mock_agent.rs• L1-45 crates/…/flow.rs• L1-15 crates/…/flow.rs• L107-169 crates/…/flow.rs• L246-320

Command-line process

The command-line process provides direct and scriptable workflows. It can use the shared agent boundary for agent-owned state or use direct hardware access when a workflow needs independent ownership. It lists devices, changes settings, runs diagnostics, manages assets, and records fixtures. See the Command-line interface page for command workflows.

Its machine-readable API is a separate external contract from internal IPC. It returns stable JSON success and error results, uses opaque device IDs, checks device writes by reading the setting back, and makes persistence explicit. A command can change live hardware without saving, while --save stages a configuration edit and asks the agent to reload the exact saved revision.

Fixture capture keeps two workflows separate. Semantic profile capture reads through the agent and produces a safe, portable profile. Raw HID fixture capture requires exclusive hardware ownership, so it cannot run beside an active agent. Direct diagnostics follow the same ownership rule; operations that depend on the agent stay on the agent path rather than silently falling back to another process.

References: crates/…/api.rs• L1-37 crates/…/api.rs• L145-271 crates/…/persistence.rs• L14-151 crates/…/tests.rs• L126-155 crates/…/tests.rs• L251-332 crates/…/agent_routing.rs• L150-191 crates/…/tests.rs• L676-815 crates/…/tests.rs• L875-935

Top-level executable

The top-level openlogi executable is the simplest command-line entry point. It starts the async runtime, calls the CLI entry point, and returns the command's exit status. The workspace keeps it as the default member, so bare Cargo build and run commands select the CLI rather than the desktop or agent.

The top-level executable stays small. The CLI library carries command behavior and the direct device, HID, camera, asset, fixture, and IPC capabilities. This keeps one command implementation available to both the packaged executable and direct development runs.

References: crates/…/main.rs• L1-11 crates/…/Cargo.toml• L1-20 crates/…/Cargo.toml• L13-29 Cargo.toml• L1-29

Overlay helper process

The Actions Ring overlay is a short-lived visual helper supervised by the agent. It receives a prepared presentation over IPC and reports user interaction back to the agent. The agent validates the session and performs the selected action, so the overlay remains a display process rather than a second device owner.

References: crates/…/main.rs• L1-105 crates/…/overlay.rs• L1-15 crates/…/agent.rs• L84-100

Process composition

Desktop-agent startup

The desktop and agent form the main interactive product pair. The desktop opens its UI without waiting for device enumeration, then connects to the agent through local IPC. If the agent is absent, the desktop uses the platform start path. After a protocol check, it declares itself as a GUI client and requests the current complete state.

The desktop keeps one live state and command link. After a crash or replacement it reconnects and requests a complete snapshot instead of replaying missed events. A deliberate application quit disables recovery during teardown, while a live newer agent is treated as a stale desktop rather than being replaced.

This diagram shows how user actions reach the process that owns hardware.

flowchart LR
    User[User] --> Desktop[Desktop application]
    Desktop -->|local IPC state and commands| Agent[Background agent]
    Agent --> Devices[Logitech devices and system input]
    Agent -->|state snapshots| Desktop
    Agent --> Overlay[Actions Ring helper]
    Overlay -->|interaction commands| Agent

References: crates/…/runtime.rs• L57-129 crates/…/ipc.rs• L1-41 crates/…/ipc.rs• L292-415 crates/…/startup.rs• L50-126 crates/…/server.rs• L1120-1152

Agent lifecycle

The agent lifecycle separates a process that can answer IPC from a process that owns hardware. Bootstrap creates shared state and the IPC service. The dormancy gate then decides whether to arm the agent. Arming starts the tray, helper, permissions, inventory, input capture, and device watchers. The running phase folds watcher events into the shared state until shutdown or replacement.

Replacement and shutdown use the same ownership boundary. Device sessions stop before the process changes binary or exits. A failed replacement keeps the current process and restarts its device watchers, while a terminal exit uses a bounded drain so disconnected hardware cannot hold the process forever.

References: crates/…/lifecycle.rs• L1-19 crates/…/lifecycle.rs• L60-88 crates/…/lifecycle.rs• L134-207 crates/…/lifecycle.rs• L210-277 crates/…/transition.rs• L20-73

Packaged process set

An installed desktop bundle groups the desktop with the helper processes that it starts. On macOS, the agent and overlay are bundled as helpers, and the desktop resolves them relative to its own executable. This keeps all runnable parts on the same build. The bundle also carries service registration data and desktop resources.

Development packaging keeps the same process shape while using matching development binaries. Production macOS startup uses the registered service. Development layouts can use a direct sibling-binary path when no login service is registered.

References: crates/…/Cargo.toml• L80-99 crates/…/build.rs• L24-127 crates/…/launch.rs• L98-124 crates/…/registration.rs• L1-13 xtask/…/dev_bundle.rs• L44-105

Auxiliary desktop windows

The desktop process owns one main window and a set of auxiliary windows. Settings, Add Device, Flow, and update consent are separate user-facing windows, while About and Updates are pages inside Settings. A window registry keeps each auxiliary window a singleton, so repeated commands focus the existing surface rather than start another copy.

These windows remain clients of shared state. The pairing window presents the agent-owned pairing session, Settings changes app-wide policy, and Flow presents cross-device coordination. Flow readiness combines saved layout and device choices with the agent's peer link state before it offers a crossing. None of these windows becomes a second owner of Logitech device I/O.

References: crates/…/windows.rs• L1-18 crates/…/windows.rs• L106-120 crates/…/windows.rs• L213-273 crates/…/add_device.rs• L1-16 crates/…/settings.rs• L397-422 crates/…/flow.rs• L115-205 crates/…/flow.rs• L339-367 crates/…/pairing.rs• L754-803

Interprocess boundary

Local IPC contract

Local IPC keeps process communication on the same machine. Unix systems use a Unix-domain socket and Windows uses a named pipe. The agent is the server. The desktop and overlay are clients. The CLI uses the same boundary for workflows that need agent-owned state, but it can use direct hardware access for separate operational workflows. See the Interprocess communication page for the service boundary and wire rules.

The contract carries complete state snapshots, commands, pairing state, diagnostics, and transient feedback. It is strict and positional. Service methods and serialized variants remain append-only, and a wire change requires a protocol-version change.

References: crates/…/lib.rs• L1-16 crates/…/transport.rs• L1-10 crates/…/ipc.rs• L26-70 crates/…/ipc.rs• L428-586 crates/…/server.rs• L1120-1152

State synchronization

The agent reports complete state with a generation number. Its observable state combines inventory, permissions, input status, Flow, pairing, foreground applications, lighting, and other client-facing facts in one value. A client asks for a generation newer than the last one it saw and holds that request until state changes or the wait ends. After reconnecting, the client asks from generation zero and receives the current state. This removes the need for a separate event replay system.

Commands and observations stay separate. The agent accepts a command, owns the operation, and returns a typed result. The desktop decides how to present that result. Pairing progress and other changing state appear in snapshots, so a delayed command result cannot replace newer user state.

References: crates/…/ipc.rs• L104-170 crates/…/ipc.rs• L545-563 crates/…/observable.rs• L36-150 crates/…/server.rs• L479-485 crates/…/ipc.rs• L1-15 crates/…/agent.rs• L56-105

Version and ownership checks

Each IPC client checks the agent's protocol version before it uses the service. A mismatch is refused rather than decoded as if both sides agreed. The client then reports which side must restart or leaves the helper role so a matching process can start.

Ownership checks protect the hardware boundary as well. The desktop and agent prevent duplicate instances, the overlay binds itself to one agent run, and direct fixture capture refuses to proceed while a live or uncertain agent endpoint exists.

References: crates/…/client.rs• L1-57 crates/…/link.rs• L78-114 crates/…/main.rs• L65-90 crates/…/takeover.rs• L44-77 crates/…/record_case.rs• L305-327 crates/…/wire_format.rs• L101-120

Change checklist

When these files or sections are changed, remember to consider these:

  • When a runnable binary name or bundle location changes, update helper lookup and bundle assembly together. Keep all helpers matched to the desktop build.
  • When the workspace default member or top-level CLI wrapper changes, check that bare Cargo commands still select the intended product entry point.
  • When the CLI API or persistence boundary changes, preserve stable JSON results, explicit save behavior, and readback checks. Keep external JSON separate from internal IPC.
  • When direct diagnostics or fixture capture changes, preserve the split between agent-owned workflows and exclusive direct hardware workflows.
  • When the IPC service or wire types change, update the protocol version and append-only service order across the agent, desktop, overlay, and CLI clients.
  • When the desktop IPC link or spawn policy changes, preserve the difference between cold start, warm reconnect, and a live newer agent. Keep production macOS recovery on the supervised service path.
  • When ownership of a device action changes, check both the client command path and the agent server path. The desktop must remain a state and command client.
  • When the observable snapshot changes, update every agent producer and every client view that consumes the affected fact. Preserve generation changes only for real state changes.
  • When a device capability or desktop feature changes, keep capability-based detail tabs, shared app state, device reads, and the corresponding feature panel aligned.
  • When camera controls change, preserve the separation between host-camera control state and agent-owned Logitech device state. Keep saved camera values, auto modes, profiles, and live hardware state aligned.
  • When a desktop window or app-wide setting changes, keep singleton window reuse, deep-link routing, live settings updates, and agent-owned side effects consistent across the main app and auxiliary windows.
  • When agent lifecycle or watcher ownership changes, keep inventory, capture, pairing, host switching, input actions, tray controls, and overlay sessions behind the same process-wide ownership and shutdown rules.
  • When configuration writes can race with another writer, preserve exact-revision confirmation and recovery before enabling dependent device controls.

Important failure modes

TriggerConsequenceGuard
Desktop and agent use different IPC versionsState and commands are refused before decoding.Clients perform a version handshake and require the matching side to restart.
Two agents start at the same timeDevice channels, input hooks, or the local endpoint can compete.A process-wide agent lock rejects duplicate ownership.
macOS starts a dormant agent without a GUI clientThe agent does not arm permissions, devices, or input capture.The GUI declares its client role before the lifecycle arms.
Agent crashes or is replaced during a desktop sessionThe desktop loses live state until a new agent answers.The desktop reconnects and requests a complete snapshot.
A desktop link arrives before inventory is completeThe requested page cannot be resolved or could open the wrong device.The desktop holds the link until a complete matching inventory arrives.
A device feature assumes an offline record has a live routeThe UI can offer a write with no valid device path.Offline records retain identity and saved state but clear the writable route.
A saved config revision changes before the agent confirms itThe desktop can show a setting that the agent did not load.The desktop reconciles the external file and waits for an exact revision receipt.
Direct HID diagnostics or fixture capture runs beside an active agentTwo processes can claim the same hardware and produce unsafe or misleading results.Direct workflows require exclusive ownership and raw interactive access refuses a live agent.
A device write succeeds but readback differsThe client can report a false success or persist a value the device rejected.CLI and desktop write flows use typed agent results and readback before persistence.
A camera is unplugged or held by another applicationThe camera panel can show no usable controls or retain a value that the hardware did not take.Camera control loading retries while the panel is visible, and failed writes rebuild the panel from live camera state.
A second auxiliary window is opened for the same taskState and user actions can split across duplicate surfaces.The window registry focuses the existing singleton.

Key files

FileWhy to read it
Cargo.tomlDefines the workspace members and the default top-level CLI member.
crates/…/main.rsShows the thin top-level executable.
crates/…/runtime.rsShows how agent updates, camera scans, asset work, and deep links feed the desktop state.
crates/…/app.rsShows the main window routes and capability-based device workspace.
crates/…/deeplink.rsShows how tray and external links reach desktop windows and device pages.
crates/…/ipc.rsShows connection startup, reconnect, snapshot delivery, and command routing.
crates/…/state.rsShows the shared desktop state and its persistence boundary.
crates/…/controls.rsShows the desktop-owned camera control and profile boundary.
crates/…/function_row.rsShows device and global binding scopes and power-user workflows.
crates/…/flow.rsShows how saved Flow layout and agent link state become crossing readiness.
crates/…/main.rsShows the agent process role and platform startup split.
crates/…/startup.rsShows the shared state and IPC service assembled before arming.
crates/…/lifecycle.rsShows dormant, armed, running, replacement, and shutdown stages.
crates/…/server.rsShows the agent-owned state and command service.
crates/…/tray_model.rsShows the platform-free model for the agent tray.
crates/…/tray.rsShows the macOS tray as a view over agent state and agent-owned device controls.
crates/…/mock_agent.rsShows the hardware-free agent used for desktop development.
crates/…/flow.rsShows scripted Flow discovery, pairing, confirmation, and saved peer state.
crates/…/api.rsDefines the machine-readable CLI contract.
crates/…/persistence.rsShows staged configuration saves and agent revision confirmation.
crates/…/main.rsShows the transient overlay process and its IPC-only role.
crates/…/ipc.rsDefines the shared state, command, client, and version contract.
crates/…/transport.rsDefines the cross-platform local endpoint.
xtask/…/dev_bundle.rsShows how the desktop and helper binaries form a runnable macOS bundle.