fix: do not show message if no battery present

This commit is contained in:
Peter Hoeg 2011-09-29 17:42:36 +08:00
commit 2c4435c73e

View file

@ -1,4 +1,4 @@
if [[ $(acpi | grep -c ^Battery) -gt 0 ]] ; then if [[ $(acpi 2&>/dev/null | grep -c ^Battery) -gt 0 ]] ; then
function battery_pct_remaining() { echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" } function battery_pct_remaining() { echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" }
function battery_time_remaining() { echo $(acpi | cut -f3 -d ',') } function battery_time_remaining() { echo $(acpi | cut -f3 -d ',') }
function battery_pct_prompt() { echo "%{$fg[red]%}[$(battery_pct_remaining)]%{$reset_color%}" } function battery_pct_prompt() { echo "%{$fg[red]%}[$(battery_pct_remaining)]%{$reset_color%}" }