Use word-regexp for osx cause we have for ex.: "AppleRawCurrentCapacity" and "CurrentCapacity"

This commit is contained in:
Aleksandr Anohin 2019-12-31 09:40:21 +02:00
commit 2798ffe214

View file

@ -81,7 +81,7 @@ __battery() {
# MacOS support
local key
for key in CurrentCapacity MaxCapacity ExternalChargeCapable FullyCharged; do
line=$(/usr/sbin/ioreg -n AppleSmartBattery -w0 | grep $key | sed -e 's/|//g' | awk '{ print $3 }')
line=$(/usr/sbin/ioreg -n AppleSmartBattery -w0 | grep -w $key | sed -e 's/|//g' | awk '{ print $3 }')
case "$key" in
CurrentCapacity) rem="$line";;
MaxCapacity) full="$line";;