You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(battery): close the gap with battery-cli — manual toggles, force-discharge, time remaining, daemon logs
Feature parity pass against actuallymentor/battery v1.3.2, all verified
live on M2 MacBook Air:
- `battery charging on|off` and `battery adapter on|off`: expose the
existing setChargingEnabled/setAdapterEnabled XPC calls in the CLI.
When a maintain policy is active the CLI warns that the toggle may be
overridden on the next evaluation (verified: it is, within seconds).
- `battery maintain N --force-discharge`: the policy actively discharges
down to the band by cutting adapter power while above the upper bound,
and restores it once inside. Persisted as battery.force_discharge in
config.toml. The evaluation loop re-asserts the cut every period,
which makes it self-healing against the firmware quirk below.
Switching back to a plain maintain hands the adapter back (daemon-side
transition, verified both directions).
- `battery status` shows time-to-empty/full from IOKit power sources
(nil while the gauge is settling — mirrors pmset's "(no estimate)").
- `daemon logs [--last 1h]`: wraps `log show` with the smctl subsystem
predicate.
Field finding that shaped the design: writing the charging-enable key
(CHTE) while an adapter cut (CHIE) is active made the SMC silently
re-enable adapter power — observed live, it stalled a one-shot
`battery discharge` forever at 79%. The one-shot discharge loop now
re-asserts the cut every poll, and force-discharge inherits immunity
from the policy loop (verified: triggering the same reset under
force-discharge is corrected within one XPC call).
PolicyEngine: BatteryObservation gains isAdapterEnabled (nil when
adapter control is unsupported — the policy then never touches the
adapter, which also keeps it out of the way of manual discharges).
New transition-matrix tests for the force-discharge branches.
0 commit comments