mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 06:23:19 -07:00
* usr/lib/byobu/battery:
- protect against division by zero
This commit is contained in:
parent
b0f059c996
commit
6e94f12096
2 changed files with 23 additions and 19 deletions
4
debian/changelog
vendored
4
debian/changelog
vendored
|
@ -1,6 +1,8 @@
|
|||
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
|
||||
|
||||
|
|
|
@ -67,25 +67,27 @@ __battery() {
|
|||
;;
|
||||
esac
|
||||
done
|
||||
percent=$(((100*$rem)/$full))
|
||||
if [ "$percent" -lt 33 ]; then
|
||||
color="R k"
|
||||
bcolor="b R k"
|
||||
elif [ "$percent" -lt 67 ]; then
|
||||
color="Y k"
|
||||
bcolor="b Y k"
|
||||
else
|
||||
color="G k"
|
||||
bcolor="b G k"
|
||||
if [ $rem -ge 0 ] && [ $full -gt 0 ]; then
|
||||
percent=$(((100*$rem)/$full))
|
||||
if [ "$percent" -lt 33 ]; then
|
||||
color="R k"
|
||||
bcolor="b R k"
|
||||
elif [ "$percent" -lt 67 ]; then
|
||||
color="Y k"
|
||||
bcolor="b Y k"
|
||||
else
|
||||
color="G k"
|
||||
bcolor="b G k"
|
||||
fi
|
||||
percent="$percent$PCT"
|
||||
case $state in
|
||||
charging|Charging|Unknown) sign="+" ;;
|
||||
discharging|Discharging) sign="-" ;;
|
||||
charged|Unknown) sign="="; percent="" ;;
|
||||
*) sign="$state" ;;
|
||||
esac
|
||||
color $bcolor; printf "%s" "$percent"; color -; color $color; printf "%s" "$sign"; color --
|
||||
fi
|
||||
percent="$percent$PCT"
|
||||
case $state in
|
||||
charging|Charging|Unknown) sign="+" ;;
|
||||
discharging|Discharging) sign="-" ;;
|
||||
charged|Unknown) sign="="; percent="" ;;
|
||||
*) sign="$state" ;;
|
||||
esac
|
||||
color $bcolor; printf "%s" "$percent"; color -; color $color; printf "%s" "$sign"; color --
|
||||
}
|
||||
|
||||
# vi: syntax=sh ts=4 noexpandtab
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue