From dc32c0b71cc263e4cec410ddcd7fac721863e29b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 21 Oct 2016 16:26:34 +1100 Subject: [PATCH 1/7] Add option to hide/show hypertheaded cpu cores --- neofetch | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 3819e310..74a48387 100755 --- a/neofetch +++ b/neofetch @@ -724,7 +724,11 @@ getcpu() { speed="$((speed / 100))" fi - cores="$(grep -c ^processor /proc/cpuinfo)" + # Show/hide hyperthreaded cores + case "$cores_ht" in + "on") cores="$(grep -c ^processor /proc/cpuinfo)" ;; + "off") cores="$(grep "^core id" /proc/cpuinfo | sort -u | wc -l)" ;; + esac # Fix for speeds under 1ghz if [ -z "${speed:1}" ]; then @@ -738,7 +742,12 @@ getcpu() { "Mac OS X") cpu="$(sysctl -n machdep.cpu.brand_string)" - cores="$(sysctl -n hw.ncpu)" + + # Show/hide hyperthreaded cores + case "$cores_ht" in + "on") cores="$(sysctl -n hw.logicalcpu_max)" ;; + "off") cores="$(sysctl -n hw.physicalcpu_max)" ;; + esac ;; "iPhone OS") From 66100fc3510f210ecaa49271720984623d898ece Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 21 Oct 2016 16:38:02 +1100 Subject: [PATCH 2/7] Use cpu_cores --- README.md | 3 ++- config/config | 4 +++- neofetch | 17 +++++++++-------- neofetch.1 | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5dcf1af3..320036fb 100644 --- a/README.md +++ b/README.md @@ -364,7 +364,8 @@ alias neofetch2="neofetch \ 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 + --cpu_cores type Whether or not to display the number of CPU cores + Takes: logical. physical, off --distro_shorthand on/off Shorten the output of distro (tiny, on, off) NOTE: This is only possible on Linux, macOS, and Solaris --kernel_shorthand on/off Shorten the output of kernel diff --git a/config/config b/config/config index d4cc28ba..54969a61 100644 --- a/config/config +++ b/config/config @@ -108,7 +108,9 @@ cpu_display="off" # CPU Cores # Display CPU cores in output -# --cpu_cores on/off +# Logical: All virtual cores +# Physical: All physical cores +# --cpu_cores logical, physical, off cpu_cores="on" diff --git a/neofetch b/neofetch index 74a48387..c5609cd9 100755 --- a/neofetch +++ b/neofetch @@ -725,9 +725,9 @@ getcpu() { fi # Show/hide hyperthreaded cores - case "$cores_ht" in - "on") cores="$(grep -c ^processor /proc/cpuinfo)" ;; - "off") cores="$(grep "^core id" /proc/cpuinfo | sort -u | wc -l)" ;; + case "$cpu_cores" in + "logical" | "on") cores="$(grep -c ^processor /proc/cpuinfo)" ;; + "physical") cores="$(grep "^core id" /proc/cpuinfo | sort -u | wc -l)" ;; esac # Fix for speeds under 1ghz @@ -744,9 +744,9 @@ getcpu() { cpu="$(sysctl -n machdep.cpu.brand_string)" # Show/hide hyperthreaded cores - case "$cores_ht" in - "on") cores="$(sysctl -n hw.logicalcpu_max)" ;; - "off") cores="$(sysctl -n hw.physicalcpu_max)" ;; + case "$cpu_cores" in + "logical" | "on") cores="$(sysctl -n hw.logicalcpu_max)" ;; + "physical") cores="$(sysctl -n hw.physicalcpu_max)" ;; esac ;; @@ -922,7 +922,7 @@ getcpu() { cpu="${cpu//with Radeon HD Graphics}" # Add cpu cores to output - [ "$cpu_cores" == "on" ] && [ "$cores" ] && \ + [ "$cpu_cores" != "off" ] && [ "$cores" ] && \ cpu="${cpu/@/(${cores}) @}" # Make the output of cpu shorter @@ -2956,7 +2956,8 @@ 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 + --cpu_cores type Whether or not to display the number of CPU cores + Takes: logical. physical, off --distro_shorthand on/off Shorten the output of distro (tiny, on, off) NOTE: This is only possible on Linux, macOS, and Solaris --kernel_shorthand on/off Shorten the output of kernel diff --git a/neofetch.1 b/neofetch.1 index 71cbf2b9..7f8ac105 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -35,7 +35,7 @@ Shorten the output of CPU .br Possible values: name, speed, tiny, on, off .TP -.B \--cpu_cores 'on/off' +.B \--cpu_cores 'logical/physical/off' Whether or not to display the number of CPU cores .TP .B \--distro_shorthand 'on/off' From bd44f1ea1201ac4150c89f604256a06f7bcbe847 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 21 Oct 2016 16:40:58 +1100 Subject: [PATCH 3/7] Fix grammar error --- README.md | 2 +- config/config | 2 +- neofetch | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 320036fb..a397316a 100644 --- a/README.md +++ b/README.md @@ -365,7 +365,7 @@ alias neofetch2="neofetch \ --cpu_shorthand type Shorten the output of CPU Possible values: name, speed, tiny, on, off --cpu_cores type Whether or not to display the number of CPU cores - Takes: logical. physical, off + Takes: logical, physical, off --distro_shorthand on/off Shorten the output of distro (tiny, on, off) NOTE: This is only possible on Linux, macOS, and Solaris --kernel_shorthand on/off Shorten the output of kernel diff --git a/config/config b/config/config index 54969a61..3a0b0eef 100644 --- a/config/config +++ b/config/config @@ -111,7 +111,7 @@ cpu_display="off" # Logical: All virtual cores # Physical: All physical cores # --cpu_cores logical, physical, off -cpu_cores="on" +cpu_cores="logical" # GPU diff --git a/neofetch b/neofetch index c5609cd9..fd6259c5 100755 --- a/neofetch +++ b/neofetch @@ -2957,7 +2957,7 @@ usage() { cat << EOF --cpu_shorthand type Shorten the output of CPU Possible values: name, speed, tiny, on, off --cpu_cores type Whether or not to display the number of CPU cores - Takes: logical. physical, off + Takes: logical, physical, off --distro_shorthand on/off Shorten the output of distro (tiny, on, off) NOTE: This is only possible on Linux, macOS, and Solaris --kernel_shorthand on/off Shorten the output of kernel From 93abca7185d4b3ed1dbc9c35c7b606aeb01dc8d8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 21 Oct 2016 16:54:05 +1100 Subject: [PATCH 4/7] Make note about support --- README.md | 1 + config/config | 1 + neofetch | 1 + neofetch.1 | 2 ++ 4 files changed, 5 insertions(+) diff --git a/README.md b/README.md index a397316a..888a2790 100644 --- a/README.md +++ b/README.md @@ -366,6 +366,7 @@ alias neofetch2="neofetch \ Possible values: name, speed, tiny, on, off --cpu_cores type Whether or not to display the number of CPU cores Takes: logical, physical, off + Note: 'physical' only works on Linux, Windows and macOS. --distro_shorthand on/off Shorten the output of distro (tiny, on, off) NOTE: This is only possible on Linux, macOS, and Solaris --kernel_shorthand on/off Shorten the output of kernel diff --git a/config/config b/config/config index 3a0b0eef..97ba2e82 100644 --- a/config/config +++ b/config/config @@ -111,6 +111,7 @@ cpu_display="off" # Logical: All virtual cores # Physical: All physical cores # --cpu_cores logical, physical, off +# Note: 'physical' only works on Linux, Windows and macOS. cpu_cores="logical" diff --git a/neofetch b/neofetch index fd6259c5..2ef2333a 100755 --- a/neofetch +++ b/neofetch @@ -2958,6 +2958,7 @@ usage() { cat << EOF Possible values: name, speed, tiny, on, off --cpu_cores type Whether or not to display the number of CPU cores Takes: logical, physical, off + Note: 'physical' only works on Linux, Windows and macOS. --distro_shorthand on/off Shorten the output of distro (tiny, on, off) NOTE: This is only possible on Linux, macOS, and Solaris --kernel_shorthand on/off Shorten the output of kernel diff --git a/neofetch.1 b/neofetch.1 index 7f8ac105..64bb852b 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -37,6 +37,8 @@ Possible values: name, speed, tiny, on, off .TP .B \--cpu_cores 'logical/physical/off' Whether or not to display the number of CPU cores +.br +Note: 'physical' only works on Linux, Windows and macOS. .TP .B \--distro_shorthand 'on/off' Shorten the output of distro (tiny, on, off) From 15ccabc5cfa40043e33a6b10e40aa135fa6bb8fa Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 21 Oct 2016 16:54:40 +1100 Subject: [PATCH 5/7] Fix grammar error --- neofetch.1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/neofetch.1 b/neofetch.1 index 64bb852b..66c58d91 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -53,7 +53,8 @@ Shorten the output of uptime (tiny, on, off) .TP .B \--refresh_rate 'on/off' Whether to display the refresh rate of each monitor -Unsupported on Windows +.br +Note: Unsupported on Windows .TP .B \--gpu_shorthand 'on/off' Shorten the output of GPU (tiny, on, off) From 988216561758e7ebf942b91e786d44b7f3b75deb Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 21 Oct 2016 20:27:35 +1100 Subject: [PATCH 6/7] Add support for Solaris --- neofetch | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 2ef2333a..2014644b 100755 --- a/neofetch +++ b/neofetch @@ -893,8 +893,11 @@ getcpu() { speed="$(psrinfo -v | awk '/operates at/ {print $6}')" speed="$((speed / 100))" - # Get cpu cores - cores="$(kstat -m cpu_info | grep -c "chip_id")" + # Show/hide hyperthreaded cores + case "$cpu_cores" in + "logical" | "on") cores="$(kstat -m cpu_info | grep -c "chip_id")" ;; + "physical") cores="$(psrinfo -p)" ;; + esac # Fix for speeds under 1ghz if [ -z "${speed:1}" ]; then From 3123548c1895688b9028c99ac1a799679ad1fca4 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 21 Oct 2016 20:29:16 +1100 Subject: [PATCH 7/7] Update docs --- README.md | 2 +- config/config | 2 +- neofetch | 2 +- neofetch.1 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 888a2790..21546035 100644 --- a/README.md +++ b/README.md @@ -366,7 +366,7 @@ alias neofetch2="neofetch \ Possible values: name, speed, tiny, on, off --cpu_cores type Whether or not to display the number of CPU cores Takes: logical, physical, off - Note: 'physical' only works on Linux, Windows and macOS. + Note: 'physical' doesn't work on BSD. --distro_shorthand on/off Shorten the output of distro (tiny, on, off) NOTE: This is only possible on Linux, macOS, and Solaris --kernel_shorthand on/off Shorten the output of kernel diff --git a/config/config b/config/config index 97ba2e82..605ed6bd 100644 --- a/config/config +++ b/config/config @@ -111,7 +111,7 @@ cpu_display="off" # Logical: All virtual cores # Physical: All physical cores # --cpu_cores logical, physical, off -# Note: 'physical' only works on Linux, Windows and macOS. +# Note: 'physical' doesn't work on BSD. cpu_cores="logical" diff --git a/neofetch b/neofetch index 2014644b..6a54d4e6 100755 --- a/neofetch +++ b/neofetch @@ -2961,7 +2961,7 @@ usage() { cat << EOF Possible values: name, speed, tiny, on, off --cpu_cores type Whether or not to display the number of CPU cores Takes: logical, physical, off - Note: 'physical' only works on Linux, Windows and macOS. + Note: 'physical' doesn't work on BSD. --distro_shorthand on/off Shorten the output of distro (tiny, on, off) NOTE: This is only possible on Linux, macOS, and Solaris --kernel_shorthand on/off Shorten the output of kernel diff --git a/neofetch.1 b/neofetch.1 index 66c58d91..62e3cd62 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -38,7 +38,7 @@ Possible values: name, speed, tiny, on, off .B \--cpu_cores 'logical/physical/off' Whether or not to display the number of CPU cores .br -Note: 'physical' only works on Linux, Windows and macOS. +Note: 'physical' doesn't work on BSD. .TP .B \--distro_shorthand 'on/off' Shorten the output of distro (tiny, on, off)