sb-cpu: """cleanup"""
This commit is contained in:
parent
a9d5afa7fe
commit
abd90c1ad5
1 changed files with 7 additions and 7 deletions
|
@ -21,23 +21,23 @@ first=true
|
|||
IFS='
|
||||
'
|
||||
for i in $(seq "$n_cpu"); do
|
||||
old_idle=$(echo "$old" | awk -v i="$i" 'NR==i { print $1 }')
|
||||
old_total=$(echo "$old" | awk -v i="$i" 'NR==i { print $2 }')
|
||||
new_idle=$(echo "$new" | awk -v i="$i" 'NR==i { print $1 }')
|
||||
new_total=$(echo "$new" | awk -v i="$i" 'NR==i { print $2 }')
|
||||
eval "$(echo "$old" | awk -v i="$i" 'NR==i { printf "old_idle=%s old_total=%s", $1, $2 }')"
|
||||
eval "$(echo "$new" | awk -v i="$i" 'NR==i { printf "new_idle=%s new_total=%s", $1, $2 }')"
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
delta_idle=$((new_idle - old_idle))
|
||||
# shellcheck disable=SC2154
|
||||
delta_total=$((new_total - old_total))
|
||||
|
||||
percent=$(((delta_total - delta_idle) * 100 / delta_total))
|
||||
|
||||
meter=$(meter_bar "$percent")
|
||||
eval "$(meter_bar "$percent" | awk -F: '{ printf "color=\"%s\" bar=\"%s\"", $1, $2 }')"
|
||||
|
||||
color=$(echo "$meter" | cut -d: -f1)
|
||||
if [ "$color" != "$prevcolor" ]; then
|
||||
$first || printf "%b" "</span>"
|
||||
printf "%b" "<span $color>"
|
||||
fi
|
||||
printf "%b" "$(echo "$meter" | cut -d: -f2)"
|
||||
printf "%b" "$bar"
|
||||
|
||||
first=false
|
||||
prevcolor=$color
|
||||
|
|
Loading…
Add table
Reference in a new issue