fix(battery): force battery percentage as integer

parent 9aeb9675
......@@ -153,7 +153,7 @@ elif [[ "$OSTYPE" = linux* ]]; then
# Battery #1 : Unknown, 99.55%
# Battery #2 : Discharging, 49.58%, 01:12:05
# All batteries : 62.60%, 02:03:03
acpitool 2>/dev/null | command awk -F, '
local -i pct=$(acpitool 2>/dev/null | command awk -F, '
/^\s+All batteries/ {
gsub(/[^0-9.]/, "", $1)
pct=$1
......@@ -164,7 +164,8 @@ elif [[ "$OSTYPE" = linux* ]]; then
pct=$2
}
END { print pct }
'
')
echo $pct
elif (( $+commands[acpi] )); then
# Sample output:
# Battery 0: Discharging, 0%, rate information unavailable
......@@ -227,7 +228,7 @@ function battery_level_gauge() {
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
local battery_remaining_percentage=$(battery_pct)
local -i battery_remaining_percentage=$(battery_pct)
local filled empty gauge_color
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment