From: Moviuro Date: Fri, 3 Oct 2014 15:24:20 +0000 (+0200) Subject: zshrc: fixed the FreeBSD battery function X-Git-Tag: v0.10.3~1 X-Git-Url: https://git.grml.org/?a=commitdiff_plain;h=a14cb097fc8c96232a6450e5c3a565b22cca64f9;p=grml-etc-core.git zshrc: fixed the FreeBSD battery function Even if there are no batteries and/or /dev/acpi is unavailable, the function won't print =% =% --- diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index a19c9ac..d3d73b1 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -1729,8 +1729,8 @@ GRML_BATTERY_LEVEL='' local num local -A table for num in 0 1 ; do - table=( ${=${${${${${(M)${(f)"$(acpiconf -i $num)"}:#(State|Remaining capacity):*}%%( ##|%)}//:[ $'\t']##/@}// /-}//@/ }} ) - if [[ $table[State] != "not-present" ]] ; then + table=( ${=${${${${${(M)${(f)"$(acpiconf -i $num 2>&1)"}:#(State|Remaining capacity):*}%%( ##|%)}//:[ $'\t']##/@}// /-}//@/ }} ) + if [[ -n $table ]] && [[ $table[State] != "not-present" ]] ; then case $table[State] in *discharging*) if (( $table[Remaining-capacity] < 20 )) ; then