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
1 changed files with 11 additions and 4 deletions

View File

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