OpenBSD's battery status get back into the BSD case

Maybe the original commiter forgot the * so s/he decided to get OpenBSD's
case nest into the `$os` instead of `$distro`.

I suspect the original reason that because OpenBSD's `$distro` output
is `OpenBSD $(uname -m)` instead of just `OpenBSD` so the results didn't
appear.

Anyway, for consistency, I decided to bring OpenBSD's battery case back
to the `$distro` case, add a very little fix (which is the *) and the
problem should be fixed.
This commit is contained in:
Muhammad Herdiansyah 2016-09-02 21:06:03 +07:00
parent ecee4e7adb
commit e51f6cf836
1 changed files with 12 additions and 12 deletions

View File

@ -1670,19 +1670,19 @@ getbattery() {
battery="$(envstat | awk '\\(|\\)' '/charge:/ {print $2}')"
battery="${battery/\.*/%}"
;;
"OpenBSD"*)
battery0full="$(sysctl -n hw.sensors.acpibat0.watthour0)"
battery0full="${battery0full/ Wh*}"
battery0now="$(sysctl -n hw.sensors.acpibat0.watthour3)"
battery0now="${battery0now/ Wh*}"
[ "$battery0full" ] && \
battery="$((100 * ${battery0now/\.} / ${battery0full/\.}))%"
;;
esac
;;
"OpenBSD")
battery0full="$(sysctl -n hw.sensors.acpibat0.watthour0)"
battery0full="${battery0full/ Wh*}"
battery0now="$(sysctl -n hw.sensors.acpibat0.watthour3)"
battery0now="${battery0now/ Wh*}"
[ "$battery0full" ] && \
battery="$((100 * ${battery0now/\.} / ${battery0full/\.}))%"
;;
;;
"Mac OS X")
battery="$(pmset -g batt | grep -o '[0-9]*%')"