Merge pull request #87 from dolmen/fix/batt

Optimize _lp_battery: no sed
This commit is contained in:
nojhan 2013-01-09 00:03:21 -08:00
commit 9685323d6a

View File

@ -746,8 +746,10 @@ _lp_battery()
[[ "$LP_ENABLE_BATT" != 1 ]] && return
local acpi
acpi="$(acpi --battery 2>/dev/null)"
local bat
bat=$( echo $acpi | sed "s/^Battery .*, \([0-9]*\)%.*$/\1/")
# Extract the battery load value in percent
# First, remove the beginning of the line...
local bat="${acpi#Battery *, }"
bat="${bat%%%*}" # remove everything starting at '%'
if [[ -z "${bat}" ]] ; then
# not battery level found