fix(power): #60 name-agnostic system-battery scan
All checks were successful
Check / eval (push) Successful in 2m53s
All checks were successful
Check / eval (push) Successful in 2m53s
Replace BAT* globs with type=Battery + !scope=Device (same filter as nomarchy-battery-notify) in charge-limit oneshot, menu gates, Waybar power-profile self-gate, doctor, and install chassis detection. CMB0- style names get charge-cap and laptop modules consistently. V3 pending: confirm on non-BAT* hardware (HARDWARE-QUEUE). Close #60. Verified: V1 (option-docs, hardware-db-modules, battery-charge-limit VM).
This commit is contained in:
@@ -232,8 +232,11 @@ else
|
||||
fi
|
||||
|
||||
# ── laptop battery charge threshold (only when a limit is set) ───────
|
||||
# Name-agnostic (BAT0, CMB0, …) — same type/scope filter as notify (#60).
|
||||
bat_seen=0; bat_limited=0
|
||||
for bat in /sys/class/power_supply/BAT*; do
|
||||
for bat in /sys/class/power_supply/*/; do
|
||||
[ "$(cat "$bat/type" 2>/dev/null)" = Battery ] || continue
|
||||
[ "$(cat "$bat/scope" 2>/dev/null || echo System)" = Device ] && continue
|
||||
f="$bat/charge_control_end_threshold"
|
||||
[ -r "$f" ] || continue
|
||||
bat_seen=1
|
||||
|
||||
@@ -227,10 +227,16 @@ nomarchy_detect_hw() {
|
||||
esac
|
||||
fi
|
||||
|
||||
# Chassis (glob test, not compgen — nixpkgs' non-interactive bash
|
||||
# is built without the completion builtins)
|
||||
local bats=(/sys/class/power_supply/BAT*)
|
||||
if [[ -e "${bats[0]}" ]]; then
|
||||
# Chassis: any system battery (type=Battery, not scope=Device) —
|
||||
# name-agnostic BAT0/CMB0/… (BACKLOG #60). Not a bare BAT* glob.
|
||||
local has_bat=0 d
|
||||
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
|
||||
has_bat=1
|
||||
break
|
||||
done
|
||||
if (( has_bat )); then
|
||||
echo "MODULE common-pc-laptop"
|
||||
echo "DETAIL chassis: laptop (battery present)"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user