* usr/lib/byobu/swap:

- clear swap status when swap usage returns to zero
This commit is contained in:
Dustin Kirkland 2015-05-21 08:25:41 -07:00
commit 7ab7a7f0ef
2 changed files with 23 additions and 17 deletions

2
debian/changelog vendored
View file

@ -2,6 +2,8 @@ byobu (5.93) unreleased; urgency=medium
* usr/bin/byobu.in: LP: #1417323 * usr/bin/byobu.in: LP: #1417323
- fix broken mv call - fix broken mv call
* usr/lib/byobu/swap:
- clear swap status when swap usage returns to zero
-- Dustin Kirkland <kirkland@ubuntu.com> Mon, 23 Mar 2015 12:50:58 -0500 -- Dustin Kirkland <kirkland@ubuntu.com> Mon, 23 Mar 2015 12:50:58 -0500

View file

@ -24,7 +24,7 @@ __swap_detail() {
} }
__swap() { __swap() {
local stotal="" sfree="" name val unit mem f; local stotal="" sfree="" name="" val="" unit="" mem="" f="";
while read name val unit; do while read name val unit; do
if [ "$name" = "SwapTotal:" ]; then if [ "$name" = "SwapTotal:" ]; then
stotal="$val" stotal="$val"
@ -35,7 +35,10 @@ __swap() {
fi fi
[ -n "$stotal" -a -n "$sfree" ] && break; [ -n "$stotal" -a -n "$sfree" ] && break;
done < /proc/meminfo done < /proc/meminfo
[ "${stotal:-0}" = "0" ] && return 0 if [ "${stotal:-0}" = "0" ]; then
printf ""
rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/swap"
else
mem=${stotal} mem=${stotal}
f=$(((100*($stotal-$sfree))/$stotal)) f=$(((100*($stotal-$sfree))/$stotal))
if [ $mem -ge 1048576 ]; then if [ $mem -ge 1048576 ]; then
@ -51,8 +54,9 @@ __swap() {
unit="$ICON_KB" unit="$ICON_KB"
fi fi
[ -n "$mem" ] || return [ -n "$mem" ] || return
color b G W; printf "s%s" "$mem"; color -; color G W; printf "%s" "$unit"; color -; color b G w; printf "s%s" "$mem"; color -; color G w; printf "%s" "$unit"; color -;
color b G W; printf "%s" "$f"; color -; color G W; printf "%s" "$PCT"; color -- color b G w; printf "%s" "$f"; color -; color G w; printf "%s" "$PCT"; color --
fi
} }
# vi: syntax=sh ts=4 noexpandtab # vi: syntax=sh ts=4 noexpandtab