mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-25 15:20:08 +00:00
fix(battery): force battery percentage as integer
This commit is contained in:
parent
9aeb967581
commit
5fb204fa74
1 changed files with 4 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue