5fb204fa7469a89f31ffb8ee8a9b3c36bea926a6

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

fix(battery): force battery percentage as integer

Diff

 1diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
 2index 0e96b00aaf7250bc687359e72f742678db488338..db5eeb93a700f8c099a05d2ac37d3df051df5cdb 100644
 3--- a/plugins/battery/battery.plugin.zsh
 4+++ b/plugins/battery/battery.plugin.zsh
 5@@ -153,7 +153,7 @@ elif [[ "$OSTYPE" = linux*  ]]; then
 6       #   Battery #1     : Unknown, 99.55%
 7       #   Battery #2     : Discharging, 49.58%, 01:12:05
 8       #   All batteries  : 62.60%, 02:03:03
 9-      acpitool 2>/dev/null | command awk -F, '
10+      local -i pct=$(acpitool 2>/dev/null | command awk -F, '
11         /^\s+All batteries/ {
12           gsub(/[^0-9.]/, "", $1)
13           pct=$1
14@@ -164,7 +164,8 @@ elif [[ "$OSTYPE" = linux*  ]]; then
15           pct=$2
16         }
17         END { print pct }
18-        '
19+        ')
20+      echo $pct
21     elif (( $+commands[acpi] )); then
22       # Sample output:
23       # Battery 0: Discharging, 0%, rate information unavailable
24@@ -227,7 +228,7 @@ function battery_level_gauge() {
25   local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
26   local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
27 
28-  local battery_remaining_percentage=$(battery_pct)
29+  local -i battery_remaining_percentage=$(battery_pct)
30   local filled empty gauge_color
31 
32   if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then