Merge pull request #1056 from julianaito/master

battery/OpenBSD: improved charge%, adds status
This commit is contained in:
Dylan Araps 2018-07-17 09:01:02 +10:00 committed by GitHub
commit 71df4ffd3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3176,12 +3176,19 @@ get_battery() {
;; ;;
"OpenBSD"* | "Bitrig"*) "OpenBSD"* | "Bitrig"*)
battery0full="$(sysctl -n hw.sensors.acpibat0.watthour0)" battery0full="$(sysctl -n hw.sensors.acpibat0.watthour0\
battery0full="${battery0full/ Wh*}" hw.sensors.acpibat0.amphour0)"
battery0full="${battery0full%% *}"
battery0now="$(sysctl -n hw.sensors.acpibat0.watthour3)" battery0now="$(sysctl -n hw.sensors.acpibat0.watthour3\
battery0now="${battery0now/ Wh*}" hw.sensors.acpibat0.amphour3)"
battery0now="${battery0now%% *}"
state="$(sysctl -n hw.sensors.acpibat0.raw0)"
state="${state##? (battery }"
state="${state%)*}"
[[ "${state}" == "charging" ]] && battery_state="charging"
[[ "$battery0full" ]] && \ [[ "$battery0full" ]] && \
battery="$((100 * ${battery0now/\.} / ${battery0full/\.}))%" battery="$((100 * ${battery0now/\.} / ${battery0full/\.}))%"
;; ;;