From 3bfcb16c089fd7eabbcd8d44a92b63902b5d49ad Mon Sep 17 00:00:00 2001 From: Reed Riley Date: Wed, 14 Sep 2016 11:21:59 -0400 Subject: [PATCH 1/2] fixed battery.plugin when acpi writes to stderr --- plugins/battery/battery.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 014bb15dd0ce..a99c28ebb3cd 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -72,7 +72,7 @@ elif [[ $(uname) == "Linux" ]] ; then function battery_pct() { if (( $+commands[acpi] )) ; then - echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" + echo "$(acpi 2&>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')" fi } @@ -86,7 +86,7 @@ elif [[ $(uname) == "Linux" ]] ; then function battery_time_remaining() { if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then - echo $(acpi | cut -f3 -d ',') + echo $(acpi 2&>/dev/null | cut -f3 -d ',') fi } From 4a4afa036f33c7c4bf82ead6e7a90b0648920330 Mon Sep 17 00:00:00 2001 From: Reed Riley Date: Wed, 14 Sep 2016 19:57:23 -0400 Subject: [PATCH 2/2] make stderr redirection in battery plugin more idiomatic --- plugins/battery/battery.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index a99c28ebb3cd..0bb9e77f0917 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -67,12 +67,12 @@ if [[ "$OSTYPE" = darwin* ]] ; then elif [[ $(uname) == "Linux" ]] ; then function battery_is_charging() { - ! [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] + ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] } function battery_pct() { if (( $+commands[acpi] )) ; then - echo "$(acpi 2&>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')" + echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')" fi } @@ -85,14 +85,14 @@ elif [[ $(uname) == "Linux" ]] ; then } function battery_time_remaining() { - if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then - echo $(acpi 2&>/dev/null | cut -f3 -d ',') + if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then + echo $(acpi 2>/dev/null | cut -f3 -d ',') fi } function battery_pct_prompt() { b=$(battery_pct_remaining) - if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then + if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then if [ $b -gt 50 ] ; then color='green' elif [ $b -gt 20 ] ; then