fix(power): #60 name-agnostic system-battery scan
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:
Bernardo Magri
2026-07-10 08:32:24 +01:00
parent 09388196a9
commit c962d07841
9 changed files with 80 additions and 29 deletions

View File

@@ -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