Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix battery.plugin when acpi writes to stderr #5413

Merged
merged 2 commits into from
Sep 15, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fixed battery.plugin when acpi writes to stderr
  • Loading branch information
reedriley committed Sep 14, 2016
commit 3bfcb16c089fd7eabbcd8d44a92b63902b5d49ad
4 changes: 2 additions & 2 deletions plugins/battery/battery.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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:]')"
Copy link
Member

@mcornella mcornella Sep 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra ampersand (&) isn't needed to redirect stderr and it's not common, though it doesn't hurt. The same applies to the other change.

fi
}

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

Expand Down