fix(power): Dell charge limit needs Custom type, not Adaptive
All checks were successful
Check / eval (push) Successful in 2m58s

charge_control_end_threshold was written (80) but charge_types stayed
[Adaptive], which ignores the cap while still reporting it — battery
kept charging past 80% on Latitude. Oneshot now selects Custom when a
limit is set, Adaptive/Standard when off; sets start hysteresis; doctor
warns if type ≠ Custom while limited.

V0: flake check --no-build green. V3: re-apply limit, confirm
charge_types shows [Custom] and status stops Charging above cap.
This commit is contained in:
2026-07-10 14:01:19 +01:00
parent 44264428af
commit 45c584db26
4 changed files with 104 additions and 14 deletions

View File

@@ -233,6 +233,8 @@ fi
# ── laptop battery charge threshold (only when a limit is set) ───────
# Name-agnostic (BAT0, CMB0, …) — same type/scope filter as notify (#60).
# Dell: Adaptive mode ignores end_threshold while still reporting the
# written value — warn if type is not Custom when a limit is active.
bat_seen=0; bat_limited=0
for bat in /sys/class/power_supply/*/; do
[ "$(cat "$bat/type" 2>/dev/null)" = Battery ] || continue
@@ -246,7 +248,15 @@ for bat in /sys/class/power_supply/*/; do
esac
if [ "$lim" -lt 100 ]; then
bat_limited=1
ok "$(basename "$bat") charge limit active at ${lim}%"
ctype=$(cat "$bat/charge_types" 2>/dev/null || cat "$bat/charge_type" 2>/dev/null || true)
active=$(printf '%s' "$ctype" | sed -n 's/.*\[\([^]]*\)\].*/\1/p')
name=$(basename "$bat")
if [ -n "$active" ] && [ "$active" != Custom ]; then
warn "$name charge limit ${lim}% but type is $active (not Custom)" \
"thresholds only apply in Custom — run: systemctl restart nomarchy-battery-charge-limit"
else
ok "$name charge limit active at ${lim}%${active:+ (type $active)}"
fi
fi
done
if [ "$bat_seen" -eq 1 ] && [ "$bat_limited" -eq 0 ]; then