From 890d44c518e04b2896a712afc2c7d24d0a654aae Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Tue, 15 Mar 2016 18:09:07 +1100 Subject: [PATCH 1/3] 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 } From 26c04cf7538f2f202d31ff2241bda885c9f91f43 Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Tue, 15 Mar 2016 18:24:12 +1100 Subject: [PATCH 2/3] changed to awk command, added netbsd and windows --- neofetch | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 9152697f..6205c858 100755 --- a/neofetch +++ b/neofetch @@ -851,7 +851,7 @@ getcpu () { cpu="$cpu @ ${speed}GHz" # Get cpu cores - cores=$(nproc) + cores=$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo) ;; "Mac OS X") @@ -897,6 +897,9 @@ getcpu () { "NetBSD"*) speed=$((speed / 10000)) ;; "Windows"*) speed=$((speed / 100000)) ;; esac + + # Get cpu cores + cores=$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo) ;; esac From c98d8f1196d321ade0315486aef736b9196a71fe Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Tue, 15 Mar 2016 18:55:35 +1100 Subject: [PATCH 3/3] added CPU cores to CPU output --- README.md | 1 + config/config | 5 +++++ neofetch | 15 +++++++++------ neofetch.1 | 3 +++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3696b7ef..1aeecf81 100644 --- a/README.md +++ b/README.md @@ -293,6 +293,7 @@ alias fetch2="fetch \ NOTE: This only support Linux with cpufreq. --cpu_shorthand type Shorten the output of CPU Possible values: name, speed, tiny, on, off + --cpu_cores on/off Whether or not to display the number of CPU cores --kernel_shorthand on/off Shorten the output of kernel --uptime_shorthand on/off Shorten the output of uptime (tiny, on, off) --gpu_shorthand on/off Shorten the output of GPU (tiny, on, off) diff --git a/config/config b/config/config index 31d671cf..7375e390 100644 --- a/config/config +++ b/config/config @@ -103,6 +103,11 @@ speed_type="max" cpu_shorthand="off" cpu_display="off" +# CPU Cores +# Display CPU cores in output +# --cpu_cores on/off +cpu_cores="on" + # GPU diff --git a/neofetch b/neofetch index 6205c858..afbe2506 100755 --- a/neofetch +++ b/neofetch @@ -125,6 +125,10 @@ speed_type="max" cpu_shorthand="off" cpu_display="off" +# CPU Cores +# Display CPU cores in output +# --cpu_cores on/off +cpu_cores="on" # GPU @@ -849,8 +853,6 @@ getcpu () { speed=${speed:0:1}.${speed:1} cpu="$cpu @ ${speed}GHz" - - # Get cpu cores cores=$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo) ;; @@ -875,8 +877,6 @@ getcpu () { "FreeBSD"*) speed=$(sysctl -n hw.clockrate) ;; esac speed=$((speed / 100)) - - # Get cpu cores cores=$(sysctl -n hw.ncpu) ;; @@ -897,8 +897,6 @@ getcpu () { "NetBSD"*) speed=$((speed / 10000)) ;; "Windows"*) speed=$((speed / 100000)) ;; esac - - # Get cpu cores cores=$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo) ;; esac @@ -924,6 +922,10 @@ getcpu () { cpu=${cpu// Eight-Core} cpu=${cpu// with Radeon HD Graphics} + # Add cpu cores to output + [ "$cpu_cores" == "on" ] && \ + cpu=${cpu/@/\(${cores}\) @} + # Make the output of cpu shorter case "$cpu_shorthand" in "name") @@ -2489,6 +2491,7 @@ usage () { cat << EOF NOTE: This only support Linux with cpufreq. --cpu_shorthand type Shorten the output of CPU Possible values: name, speed, tiny, on, off + --cpu_cores on/off Whether or not to display the number of CPU cores --kernel_shorthand on/off Shorten the output of kernel --uptime_shorthand on/off Shorten the output of uptime (tiny, on, off) --gpu_shorthand on/off Shorten the output of GPU (tiny, on, off) diff --git a/neofetch.1 b/neofetch.1 index af8716fc..b2132234 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -41,6 +41,9 @@ Shorten the output of CPU .br Possible values: name, speed, tiny, on, off .TP +.B \--cpu_cores 'on/off' +Whether or not to display the number of CPU cores +.TP .B \--kernel_shorthand 'on/off' Shorten the output of kernel .TP