Reliably autodetect battery device in statusbar

Wireless devices have "Wireless" type, so we search for nodes with type
"Battery". We also may handle wireless devices that way, if anyone needs
that.

Signed-off-by: Stacy Harper <contact@stacyharper.net>
master
Maxim Karasev 3 years ago committed by Stacy Harper
parent df11b22b51
commit 6c161a11ca
No known key found for this signature in database
GPG Key ID: 5BAC92328B7C5D65
  1. 14
      scripts/core/sxmo_statusbar.sh

@ -54,12 +54,14 @@ update() {
fi fi
fi fi
# Battery pct # Find battery and get percentage + status
BATTERY_DEVICE="${BATTERY_DEVICE:-"/sys/class/power_supply/axp20x-battery"}" for power_supply in /sys/class/power_supply/*; do
PCT="$(cat "$BATTERY_DEVICE"/capacity)" if [ "$(cat "$power_supply"/type)" = "Battery" ]; then
BATSTATUS="$( PCT="$(cat "$power_supply"/capacity)"
cut -c1 "$BATTERY_DEVICE"/status BATSTATUS="$(cut -c1 "$power_supply"/status)"
)" fi
done
if [ "$BATSTATUS" = "C" ]; then if [ "$BATSTATUS" = "C" ]; then
if [ "$PCT" -lt 20 ]; then if [ "$PCT" -lt 20 ]; then
BATSTATUS="$PCT% " BATSTATUS="$PCT% "

Loading…
Cancel
Save