From 1332874265a703ba4e44b8db7bfe95bbf0424a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne?= Date: Mon, 16 Jul 2018 22:58:47 +0200 Subject: [PATCH] battery/OpenBSD: improved charge%, adds status This commit adds support for hw.sensors.acpibat0.amphour[03] for battery charge statistics in addition to watthour[03]. It also adds charging status. --- neofetch | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index a781e224..d8be94f5 100755 --- a/neofetch +++ b/neofetch @@ -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/\.}))%" ;;