Last updated: August 2025
Framework System TUI is a Rust-based dashboard that controls and monitors Framework laptop hardware from a terminal interface. It provides real-time data and interactive controls, organized into UI panels, using the ratatui library, and connects to hardware via the framework_lib crate.
- Separation of Concerns: UI logic (App) and hardware interface (Framework) are strictly isolated.
- Periodic Polling: Hardware status is updated at a fixed interval.
- Panelized UI: Each type of hardware info/control is presented in a dedicated TUI panel.
- Error Handling: Uses
color-eyrethroughout for robust reporting.
| Module | Path | Purpose |
|---|---|---|
| Main | src/main.rs |
App entrypoint. Sets up TUI environment, runs App. |
| App | src/app.rs |
Event/render loop. Owns Framework; handles UI, input. |
| Framework | src/framework.rs |
Manages hardware polling. Wraps EC and telemetry. |
| FrameworkInfo | src/framework/info.rs |
Aggregates all hardware data for UI panels. |
| Tui & Components | src/tui/ |
Panels, layout, input handling in TUI. |
- App Startup:
main.rssets up terminal and starts App. - Event Loop:
Appperiodically polls hardware viaFramework. - Framework Polling:
Frameworkcollects hardware info at interval, parses state toFrameworkInfo. - UI Panels:
Apprenders state for distinct panels (battery, privacy, lighting, SMBIOS, PD ports etc). - User Actions: Keyboard input dispatched to
App, which may trigger hardware mutations viaFramework.
graph TD
Main["main.rs: main()"]
App["app.rs: App"]
Framework["framework.rs: Framework"]
Info["framework/info.rs: FrameworkInfo"]
Tui["tui/"]
Hardware["framework_lib (HW APIs)"]
Main --> App
App --> Framework
Framework --> Info
Info --> Tui
Framework -->|polls| Hardware
App --> Tui
Tui -->|renders| User["User"]
User --> App
sequenceDiagram
participant User
participant Terminal
participant App
participant Framework
participant HW
User->>Terminal: Keyboard Input
Terminal->>App: Key Events
App->>Framework: poll_if_needed()
Framework->>HW: Query hardware APIs
HW-->>Framework: Return telemetry
Framework-->>App: FrameworkInfo (snapshot)
App-->>Terminal: Render UI
- Framework polls hardware at fixed
poll_interval. - Polling gathers:
- Battery, charge %, power
- Privacy status (cam/mic)
- Brightness (keyboard, fingerprint)
- SMBIOS info
- PD ports
- State stored in FrameworkInfo then visualized by App.
Main (src/main.rs)
- Entry point.
- Sets up color-eyre, initializes
ratatui, runsApp::run().
App (src/app.rs)
- Owns Framework and Tui.
- Handles event loop:
- Polls Framework for updates.
- Renders info in panels.
- Handles keyboard input, dispatches actions (quit, set charge limit, adjust brightness).
Framework (src/framework.rs)
- Wraps underlying EC API (
CrosEcfrom framework_lib). - Exposes hardware mutation methods (set charge limit, set brightness).
- Polls all hardware data, collects into
FrameworkInfo. - Decoupled from UI logic.
FrameworkInfo (src/framework/info.rs)
- Captures all hardware states as fields.
- Passed to TUI panels for display.
TUI (src/tui/)
- Panels implemented in submodules:
- Battery, Charge, Privacy, SMBIOS, Brightness, PD Ports, Footer, Title
- Input routing, layout management, rendering via ratatui.
App(owns Framework, Info, TUI, controls lifecycle)Framework(owns hardware abstraction, polling logic)FrameworkInfo(complete telemetry snapshot for UI)Tuiand panel objects
- New hardware features added by extending
FrameworkInfoand panel submodules. - Platform independence maintained by isolating hardware logic in Framework.
Licensed under the terms detailed in Cargo.toml.