From e51f6cf8369d51cc07e8d8e52efdcfc92fdb91bb Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Fri, 2 Sep 2016 21:06:03 +0700 Subject: [PATCH] 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. --- neofetch | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/neofetch b/neofetch index 40352a73..76e2f1cf 100755 --- a/neofetch +++ b/neofetch @@ -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]*%')"