feat: better handle 2 batteries

This commit is contained in:
David JULIEN 2021-09-09 22:18:20 +02:00
parent 0aa8c15431
commit bf8804a467

View File

@ -37,20 +37,23 @@ do
status="$(cat "$bat/status")" status="$(cat "$bat/status")"
capacity="$(cat "$bat/capacity")" capacity="$(cat "$bat/capacity")"
total="$(expr $total + $capacity)" total="$(expr $total + $capacity)"
slot="$(basename $bat)"
if [ "$status" = "Full" ]; then if [ "$status" = "Full" ]; then
status=" " && capacity="FULL" status=" " && capacity="FULL"
printf " %s %s " "$status" "$capacity" && exit printf " %s:%s(%s) " "$slot" "$status" "$capacity"
elif [ "$status" = "Charging" ]; then else
status="" if [ "$status" = "Charging" ]; then
else status=""
case "$capacity" in else
100|[8-9][0-9]) status="" ;; case "$capacity" in
[6-7][0-9]) status="" ;; 100|[8-9][0-9]) status="" ;;
[4-5][0-9]) status="" ;; [6-7][0-9]) status="" ;;
[2-3][0-9]) status="" ;; [4-5][0-9]) status="" ;;
*) status="" ;; [2-3][0-9]) status="" ;;
esac *) status="" ;;
fi esac
[ 40 -gt $total ] && notify; fi
printf " %s %3d%% " "$status" "$capacity"; [ 40 -gt $total ] && notify;
printf " %s:%s (%0.2d%%) " "$slot" "$status" "$capacity";
fi
done done