* usr/lib/byobu/battery:

- protect against division by zero
This commit is contained in:
Dustin Kirkland 2011-10-26 09:41:17 -05:00
commit 6e94f12096
2 changed files with 23 additions and 19 deletions

4
debian/changelog vendored
View file

@ -1,6 +1,8 @@
byobu (4.44) unreleased; urgency=low byobu (4.44) unreleased; urgency=low
* UNRELEASED [ Dustin Kirkland ]
* usr/lib/byobu/battery:
- protect against division by zero
-- Dustin Kirkland <kirkland@ubuntu.com> Sat, 22 Oct 2011 03:21:46 -0500 -- Dustin Kirkland <kirkland@ubuntu.com> Sat, 22 Oct 2011 03:21:46 -0500

View file

@ -67,6 +67,7 @@ __battery() {
;; ;;
esac esac
done done
if [ $rem -ge 0 ] && [ $full -gt 0 ]; then
percent=$(((100*$rem)/$full)) percent=$(((100*$rem)/$full))
if [ "$percent" -lt 33 ]; then if [ "$percent" -lt 33 ]; then
color="R k" color="R k"
@ -86,6 +87,7 @@ __battery() {
*) sign="$state" ;; *) sign="$state" ;;
esac esac
color $bcolor; printf "%s" "$percent"; color -; color $color; printf "%s" "$sign"; color -- color $bcolor; printf "%s" "$percent"; color -; color $color; printf "%s" "$sign"; color --
fi
} }
# vi: syntax=sh ts=4 noexpandtab # vi: syntax=sh ts=4 noexpandtab