Merge pull request #87 from dolmen/fix/batt
Optimize _lp_battery: no sed
This commit is contained in:
commit
9685323d6a
@ -746,8 +746,10 @@ _lp_battery()
|
|||||||
[[ "$LP_ENABLE_BATT" != 1 ]] && return
|
[[ "$LP_ENABLE_BATT" != 1 ]] && return
|
||||||
local acpi
|
local acpi
|
||||||
acpi="$(acpi --battery 2>/dev/null)"
|
acpi="$(acpi --battery 2>/dev/null)"
|
||||||
local bat
|
# Extract the battery load value in percent
|
||||||
bat=$( echo $acpi | sed "s/^Battery .*, \([0-9]*\)%.*$/\1/")
|
# First, remove the beginning of the line...
|
||||||
|
local bat="${acpi#Battery *, }"
|
||||||
|
bat="${bat%%%*}" # remove everything starting at '%'
|
||||||
|
|
||||||
if [[ -z "${bat}" ]] ; then
|
if [[ -z "${bat}" ]] ; then
|
||||||
# not battery level found
|
# not battery level found
|
||||||
|
Loading…
x
Reference in New Issue
Block a user