macstate
macOS system signals as JSON — a CLI and a Rust library.
Surfaces signals that aren't directly readable from the shell:
- Network — Low Data Mode (
constrained), expensive link (cellular/hotspot), interface kind - Power — AC vs battery, battery percent, Low Power Mode, Energy Mode (automatic/low/high)
low_power_mode reports the currently active state (via
NSProcessInfo.isLowPowerModeEnabled); energy_mode reports the
configured preference for the current power source (AC or Battery)
read from IOKit's active PM preferences — the same source pmset uses.
macOS only.
Install
From crates.io (requires a Rust toolchain):
Prebuilt binary via cargo-binstall (no toolchain needed):
Or pin to the bleeding edge from git:
Update any of the above with --force.
Usage
Default: print everything as JSON and exit.
{
}
Subsets:
Single value at a dotted path:
Shell guard via exit code (true → 0, false → 1):
&&
JSON Schema for the output (useful for AI agents and downstream tools):
The schema is generated from the Rust types at runtime via
schemars, so it always matches
what the CLI actually emits.
Library
[]
= "0.0"
let state = collect;
println!;
License
BSD 3-Clause. See LICENSE.