Skip to content

Commit

Permalink
Fix battery plugin when acpi writes to stderr (ohmyzsh#5413)
Browse files Browse the repository at this point in the history
* Fix battery plugin when acpi writes to stderr
* Make stderr redirection in battery plugin more idiomatic
  • Loading branch information
reedriley authored and mcornella committed Sep 15, 2016
1 parent ce4d8a5 commit 59c66db
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plugins/battery/battery.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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 | cut -f2 -d ',' | tr -cd '[:digit:]')"
echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')"
fi
}

Expand All @@ -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 | 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
Expand Down

0 comments on commit 59c66db

Please sign in to comment.