From 15a03744a9e87b8dd371a4fbac456a73d27d32d5 Mon Sep 17 00:00:00 2001 From: GregoireW Date: Thu, 17 Oct 2019 11:30:24 +0200 Subject: [PATCH] Remove invalid batteries (#8275) --- plugins/battery/battery.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index d1adcd0b6..6fe801c9f 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -112,12 +112,12 @@ elif [[ "$OSTYPE" = freebsd* ]]; then elif [[ "$OSTYPE" = linux* ]]; then function battery_is_charging() { - ! acpi 2>/dev/null | command grep -q '^Battery.*Discharging' + ! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging' } function battery_pct() { if (( $+commands[acpi] )); then - acpi 2>/dev/null | command grep -E '^Battery.*(Disc|C)harging' | cut -f2 -d ',' | tr -cd '[:digit:]' + acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Disc|C)harging' | cut -f2 -d ',' | tr -cd '[:digit:]' fi } @@ -131,7 +131,7 @@ elif [[ "$OSTYPE" = linux* ]]; then function battery_time_remaining() { if ! battery_is_charging; then - acpi 2>/dev/null | cut -f3 -d ',' + acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ',' fi }