Fix cpu usage

This commit is contained in:
Dylan Araps 2016-06-13 19:40:54 +10:00
parent efcc7e8273
commit d65aa4bc6b

View file

@ -1149,13 +1149,13 @@ getcpu () {
if [ "$cpu_display" != "off" ]; then if [ "$cpu_display" != "off" ]; then
cpu_usage="$(ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }')" cpu_usage="$(ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }')"
cpu_usage="${cpu_usage/\.*}%" cpu_usage=$((${cpu_usage/\.*} / cores))
case "$cpu_display" in case "$cpu_display" in
"info") prin "$subtitle Usage" "$cpu_usage" ;; "info") prin "$subtitle Usage" "${cpu_usage}%" ;;
"bar") prin "$subtitle Usage" "$(bar "${cpu_usage/'%'}" $(( 100 * cores )))" ;; "bar") prin "$subtitle Usage" "$(bar "$cpu_usage" 100)" ;;
"infobar") prin "$subtitle Usage" "${cpu_usage} $(bar "${cpu_usage/'%'}" $(( 100 * cores )))" ;; "infobar") prin "$subtitle Usage" "${cpu_usage}% $(bar $cpu_usage 100)" ;;
"barinfo") prin "$subtitle Usage" "$(bar "${cpu_usage/'%'}" $(( 100 * cores ))) $cpu_usage" ;; "barinfo") prin "$subtitle Usage" "$(bar $cpu_usage 100) ${cpu_usage}%" ;;
esac esac
fi fi
[ "$stdout_mode" != "on" ] && unset cpu [ "$stdout_mode" != "on" ] && unset cpu