From 890d44c518e04b2896a712afc2c7d24d0a654aae Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Tue, 15 Mar 2016 18:09:07 +1100 Subject: [PATCH] added cpu cores so the usage bar doesn't go crazy above 100% --- neofetch | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 751ceacb..9152697f 100755 --- a/neofetch +++ b/neofetch @@ -849,11 +849,15 @@ getcpu () { speed=${speed:0:1}.${speed:1} cpu="$cpu @ ${speed}GHz" + + # Get cpu cores + cores=$(nproc) ;; "Mac OS X") cpu="$(sysctl -n machdep.cpu.brand_string)" cpu=${cpu/ } + cores=$(sysctl -n hw.ncpu) ;; *"BSD" | "Windows") @@ -871,6 +875,9 @@ getcpu () { "FreeBSD"*) speed=$(sysctl -n hw.clockrate) ;; esac speed=$((speed / 100)) + + # Get cpu cores + cores=$(sysctl -n hw.ncpu) ;; "NetBSD"* | "Windows"*) @@ -888,7 +895,7 @@ getcpu () { case "$distro" in "NetBSD"*) speed=$((speed / 10000)) ;; - "WindowS"*) speed=$((speed / 100000)) ;; + "Windows"*) speed=$((speed / 100000)) ;; esac ;; esac @@ -944,9 +951,9 @@ getcpu () { case "$cpu_display" in "info") prin "${subtitle} Usage: ${cpu_usage}" ;; - "bar") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" 100)" ;; - "infobar") prin "${subtitle} Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" 100)" ;; - "barinfo") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" 100) ${cpu_usage}" ;; + "bar") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} )))" ;; + "infobar") prin "${subtitle} Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} )))" ;; + "barinfo") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} ))) ${cpu_usage}" ;; esac unset cpu }