How shark-empire/mitos-power works
mitos-power is MITOS’s central power-management daemon, exposing battery, profile, display, thermal, sleep, shutdown and inhibitor operations through a Unix-socket API. The main workflow is a local client request or hardware/event update entering the daemon, reaching the PowerManager and relevant subsystem, then producing a response or broadcast event. Configuration initializes behavior; policy and scheduling add automated actions. The README documents the broader capability set, while sampled excerpts substantiate IPC dispatch, manager coordination, profiles, inhibitors and thermal handling; links for unsampled internals are limited accordingly.
Main entry points: manager.rs PowerManager · server.rs Unix IPC server · mod.rs Hardware access · mitos-powerctl.rs powerctl CLI
Components 24
Entry and API
- powerctl CLI
bin/mitos-powerctl.rs - Daemon runtime
src/daemon/daemon.rs - Unix IPC server
src/ipc/server.rs - IPC protocol
src/ipc/protocol.rs - Configuration
src/config/mod.rs
Management and policy
- PowerManager
src/manager/manager.rs - Policy engine
src/manager/policy.rs - Operation scheduler
src/manager/scheduler.rs - Inhibitor registry
src/inhibitor/manager.rs
Power features
- Power profiles
src/profiles/manager.rs - Battery monitoring
src/battery/mod.rs - AC detection
src/ac/mod.rs - Display controls
src/display/mod.rs - CPU controls
src/cpu/mod.rs - Thermal monitoring
src/thermal/mod.rs - Idle behavior
src/idle/mod.rs - Sleep operations
src/sleep/mod.rs - Shutdown operations
src/shutdown/mod.rs
Hardware and state
- Device events
src/devices/mod.rs - Hardware access
src/hardware/mod.rs - Daemon events
src/ipc/events.rs - Persistent state
src/persistence/database.rs
Other components
- MITOS clients
- Linux kernel interfaces
Connections 31
- MITOS clients → powerctl CLI: invokes
- powerctl CLI → Unix IPC server: sends requests
- MITOS clients → Unix IPC server: connects
- Unix IPC server → IPC protocol: decodes messages
- Unix IPC server → PowerManager: dispatches requests
- Daemon runtime → Unix IPC server: runs server
- Configuration → Daemon runtime: configures startup
- PowerManager → Policy engine: runs policy
- PowerManager → Power profiles: selects profiles
- PowerManager → Inhibitor registry: checks blockers
- PowerManager → Operation scheduler: schedules operations
- PowerManager → Battery monitoring: reads battery state
- PowerManager → AC detection: reads AC state
- PowerManager → Display controls: controls display
- PowerManager → CPU controls: applies CPU settings
- PowerManager → Thermal monitoring: reads thermal state
- PowerManager → Idle behavior: manages idle state
- PowerManager → Sleep operations: invokes sleep
- PowerManager → Shutdown operations: invokes shutdown
- PowerManager → Daemon events: publishes events
- Unix IPC server → Daemon events: forwards subscriptions
- Unix IPC server → Inhibitor registry: releases on disconnect
- Device events → PowerManager: reports device state
- Battery monitoring → Hardware access: reads hardware
- AC detection → Hardware access: detects power source
- Thermal monitoring → Hardware access: reads thermal zones
- Display controls → Hardware access: writes display controls
- CPU controls → Hardware access: writes CPU controls
- Sleep operations → Linux kernel interfaces: requests sleep
- Shutdown operations → Linux kernel interfaces: requests power action
- Persistent state → PowerManager: stores state