fix(power): Dell charge limit needs Custom type, not Adaptive
All checks were successful
Check / eval (push) Successful in 2m58s
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:
@@ -157,7 +157,7 @@ let
|
||||
" <span size='small' alpha='55%'>${prettyKeys (lib.head m)}</span>";
|
||||
menuHint = module: hintForAction "exec, nomarchy-menu ${module}";
|
||||
# Apps opens rofi drun directly, not a nomarchy-menu module.
|
||||
appsHint = " <span size='small' alpha='55%'>SUPER + D</span>";
|
||||
appsHint = " <span size='small' alpha='55%'>SUPER + Space</span>";
|
||||
# A menu row that runs the same op as a global bind whose action isn't a
|
||||
# `nomarchy-menu` module (the Capture rows ↔ the Print screenshot keys):
|
||||
# match on mods+key so the hint still reads from keybinds.nix (single
|
||||
@@ -327,6 +327,7 @@ let
|
||||
set_limit() {
|
||||
nomarchy-theme-sync --quiet set settings.power.batteryChargeLimit "$1" --no-switch
|
||||
n="$1"; [ "$n" = null ] && n=100
|
||||
# Root oneshot sets Custom charge type (Dell) + thresholds.
|
||||
applied=
|
||||
if systemctl restart nomarchy-battery-charge-limit.service 2>/dev/null; then
|
||||
applied=1
|
||||
@@ -334,21 +335,34 @@ let
|
||||
for d in /sys/class/power_supply/*/; do
|
||||
[ "$(cat "$d/type" 2>/dev/null)" = Battery ] || continue
|
||||
[ "$(cat "$d/scope" 2>/dev/null || echo System)" = Device ] && continue
|
||||
if [ "$n" -lt 100 ] 2>/dev/null; then
|
||||
for tnode in charge_types charge_type; do
|
||||
[ -w "$d$tnode" ] || continue
|
||||
listed=$(cat "$d$tnode" 2>/dev/null || true)
|
||||
case " $listed " in *" Custom "*|*"Custom"*) echo Custom > "$d$tnode" 2>/dev/null || true ;; esac
|
||||
done
|
||||
fi
|
||||
thresh="$d/charge_control_end_threshold"
|
||||
if [ -w "$thresh" ] && echo "$n" > "$thresh" 2>/dev/null; then
|
||||
applied=1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
actual=
|
||||
actual=; ctype=
|
||||
for d in /sys/class/power_supply/*/; do
|
||||
[ "$(cat "$d/type" 2>/dev/null)" = Battery ] || continue
|
||||
[ "$(cat "$d/scope" 2>/dev/null || echo System)" = Device ] && continue
|
||||
[ -r "$d/charge_control_end_threshold" ] \
|
||||
&& actual=$(cat "$d/charge_control_end_threshold" 2>/dev/null) && break
|
||||
&& actual=$(cat "$d/charge_control_end_threshold" 2>/dev/null)
|
||||
ctype=$(cat "$d/charge_types" 2>/dev/null || cat "$d/charge_type" 2>/dev/null || true)
|
||||
[ -n "$actual" ] && break
|
||||
done
|
||||
# Highlight active type: "… [Custom] …"
|
||||
active=$(printf '%s' "$ctype" | sed -n 's/.*\[\([^]]*\)\].*/\1/p')
|
||||
extra=
|
||||
[ -n "$active" ] && extra=" (type $active)"
|
||||
if [ -n "$applied" ] && [ -n "$actual" ]; then
|
||||
notify-send "Battery limit" "$2 — sysfs now $actual%."
|
||||
notify-send "Battery limit" "$2 — stop at $actual%$extra."
|
||||
elif [ -n "$applied" ]; then
|
||||
notify-send "Battery limit" "$2 — applied (could not re-read sysfs)."
|
||||
else
|
||||
@@ -970,21 +984,32 @@ ${themeRows}
|
||||
for d in /sys/class/power_supply/*/; do
|
||||
[ "$(cat "$d/type" 2>/dev/null)" = Battery ] || continue
|
||||
[ "$(cat "$d/scope" 2>/dev/null || echo System)" = Device ] && continue
|
||||
if [ "$n" -lt 100 ] 2>/dev/null; then
|
||||
for tnode in charge_types charge_type; do
|
||||
[ -w "$d$tnode" ] || continue
|
||||
listed=$(cat "$d$tnode" 2>/dev/null || true)
|
||||
case " $listed " in *" Custom "*|*"Custom"*) echo Custom > "$d$tnode" 2>/dev/null || true ;; esac
|
||||
done
|
||||
fi
|
||||
thresh="$d/charge_control_end_threshold"
|
||||
if [ -w "$thresh" ] && echo "$n" > "$thresh" 2>/dev/null; then
|
||||
applied=1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
actual=
|
||||
actual=; ctype=
|
||||
for d in /sys/class/power_supply/*/; do
|
||||
[ "$(cat "$d/type" 2>/dev/null)" = Battery ] || continue
|
||||
[ "$(cat "$d/scope" 2>/dev/null || echo System)" = Device ] && continue
|
||||
[ -r "$d/charge_control_end_threshold" ] \
|
||||
&& actual=$(cat "$d/charge_control_end_threshold" 2>/dev/null) && break
|
||||
&& actual=$(cat "$d/charge_control_end_threshold" 2>/dev/null)
|
||||
ctype=$(cat "$d/charge_types" 2>/dev/null || cat "$d/charge_type" 2>/dev/null || true)
|
||||
[ -n "$actual" ] && break
|
||||
done
|
||||
active=$(printf '%s' "$ctype" | sed -n 's/.*\[\([^]]*\)\].*/\1/p')
|
||||
extra=; [ -n "$active" ] && extra=" (type $active)"
|
||||
if [ -n "$applied" ] && [ -n "$actual" ]; then
|
||||
notify-send "Battery limit" "$2 — sysfs now $actual%."
|
||||
notify-send "Battery limit" "$2 — stop at $actual%$extra."
|
||||
elif [ -n "$applied" ]; then
|
||||
notify-send "Battery limit" "$2 — applied (could not re-read sysfs)."
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user