Battery: Add support for Bay Trail devices (axp288_fuel_gauge)

This commit is contained in:
Michael Straube 2017-04-08 15:28:39 +02:00
parent 15451a5283
commit d8e1150e19
1 changed files with 13 additions and 15 deletions

View File

@ -1833,26 +1833,24 @@ get_disk() {
get_battery() { get_battery() {
case "$os" in case "$os" in
"Linux") "Linux")
# We use 'prin' here and exit the function early so that we can # We use 'prin' here so that we can do multi battery support
# do multi battery support with a single battery per line. # with a single battery per line.
for bat in "/sys/class/power_supply/BAT"*; do for bat in "/sys/class/power_supply/"{BAT,axp288_fuel_gauge}*; do
capacity="$(< "${bat}/capacity")" capacity="$(< "${bat}/capacity")"
status="$(< "${bat}/status")" status="$(< "${bat}/status")"
# Fix for bash on Windows 10 which includes /proc files if [[ "$capacity" ]]; then
# for battery usage despite there not being a battery battery="${capacity}% [${status}]"
# installed.
[[ -z "$capacity" ]] && return
battery="${capacity}% [${status}]" case "$battery_display" in
"bar") battery="$(bar "$capacity" 100)" ;;
"infobar") battery+=" $(bar "$capacity" 100)" ;;
"barinfo") battery="$(bar "$capacity" 100)${info_color} ${battery}" ;;
esac
case "$battery_display" in bat="${bat/*axp288_fuel_gauge}"
"bar") battery="$(bar "$capacity" 100)" ;; prin "${subtitle:+${subtitle}${bat: -1}}" "$battery"
"infobar") battery+=" $(bar "$capacity" 100)" ;; fi
"barinfo") battery="$(bar "$capacity" 100)${info_color} ${battery}" ;;
esac
prin "${subtitle:+${subtitle}${bat: -1}}" "$battery"
done done
return return
;; ;;