How crazydw4rf/caffeinate works
caffeinate is a small Rust daemon that watches PipeWire node activity and holds a systemd-logind idle inhibitor while audio is running. The workflow is single-instance startup, audio-state detection, then acquiring or releasing the inhibitor. Runtime behavior is implemented in src/main.rs; no separate modules are present.
Main entry points: main.rs Caffeinate runtime
Components 11
Audio monitoring
- Caffeinate runtime
src/main.rs - PipeWire
- Node state listener
src/main.rs
Idle inhibition
- Audio state channel
src/main.rs - Inhibit worker
src/main.rs - Inhibitor file descriptor
src/main.rs
System interfaces
- Instance lock
src/main.rs - Lock file
- systemd-logind
Other components
- User
- Audio playback
Connections 11
- User → Caffeinate runtime: starts
- Caffeinate runtime → Instance lock: checks instance
- Instance lock → Lock file: locks
- Audio playback → PipeWire: creates audio nodes
- Caffeinate runtime → PipeWire: connects and registers
- PipeWire → Node state listener: reports node states
- Node state listener → Audio state channel: sends audio state
- Audio state channel → Inhibit worker: delivers state
- Inhibit worker → systemd-logind: requests idle inhibitor
- systemd-logind → Inhibitor file descriptor: returns descriptor
- Inhibit worker → Inhibitor file descriptor: holds or releases