diff --git a/README.md b/README.md index 5dcf1af3..21546035 100644 --- a/README.md +++ b/README.md @@ -364,7 +364,9 @@ 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 + 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 d4cc28ba..605ed6bd 100644 --- a/config/config +++ b/config/config @@ -108,8 +108,11 @@ cpu_display="off" # CPU Cores # Display CPU cores in output -# --cpu_cores on/off -cpu_cores="on" +# Logical: All virtual cores +# Physical: All physical cores +# --cpu_cores logical, physical, off +# Note: 'physical' doesn't work on BSD. +cpu_cores="logical" # GPU diff --git a/neofetch b/neofetch index 5b9cf92a..2bb72b09 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 "$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 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 "$cpu_cores" in + "logical" | "on") cores="$(sysctl -n hw.logicalcpu_max)" ;; + "physical") cores="$(sysctl -n hw.physicalcpu_max)" ;; + esac ;; "iPhone OS") @@ -884,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 @@ -913,7 +925,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 @@ -2948,7 +2960,9 @@ 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 + 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 71cbf2b9..62e3cd62 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -35,8 +35,10 @@ 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 +.br +Note: 'physical' doesn't work on BSD. .TP .B \--distro_shorthand 'on/off' Shorten the output of distro (tiny, on, off) @@ -51,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)