added cpu cores so the usage bar doesn't go crazy above 100%

This commit is contained in:
Andrew Titmuss 2016-03-15 18:09:07 +11:00
parent b5c76c0dc3
commit 890d44c518
1 changed files with 11 additions and 4 deletions

View File

@ -849,11 +849,15 @@ getcpu () {
speed=${speed:0:1}.${speed:1} speed=${speed:0:1}.${speed:1}
cpu="$cpu @ ${speed}GHz" cpu="$cpu @ ${speed}GHz"
# Get cpu cores
cores=$(nproc)
;; ;;
"Mac OS X") "Mac OS X")
cpu="$(sysctl -n machdep.cpu.brand_string)" cpu="$(sysctl -n machdep.cpu.brand_string)"
cpu=${cpu/ } cpu=${cpu/ }
cores=$(sysctl -n hw.ncpu)
;; ;;
*"BSD" | "Windows") *"BSD" | "Windows")
@ -871,6 +875,9 @@ getcpu () {
"FreeBSD"*) speed=$(sysctl -n hw.clockrate) ;; "FreeBSD"*) speed=$(sysctl -n hw.clockrate) ;;
esac esac
speed=$((speed / 100)) speed=$((speed / 100))
# Get cpu cores
cores=$(sysctl -n hw.ncpu)
;; ;;
"NetBSD"* | "Windows"*) "NetBSD"* | "Windows"*)
@ -888,7 +895,7 @@ getcpu () {
case "$distro" in case "$distro" in
"NetBSD"*) speed=$((speed / 10000)) ;; "NetBSD"*) speed=$((speed / 10000)) ;;
"WindowS"*) speed=$((speed / 100000)) ;; "Windows"*) speed=$((speed / 100000)) ;;
esac esac
;; ;;
esac esac
@ -944,9 +951,9 @@ getcpu () {
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)" ;; "bar") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} )))" ;;
"infobar") prin "${subtitle} Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" 100)" ;; "infobar") prin "${subtitle} Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} )))" ;;
"barinfo") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" 100) ${cpu_usage}" ;; "barinfo") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} ))) ${cpu_usage}" ;;
esac esac
unset cpu unset cpu
} }