Use cpu_cores

This commit is contained in:
Dylan Araps 2016-10-21 16:38:02 +11:00
parent dc32c0b71c
commit 66100fc351
4 changed files with 15 additions and 11 deletions

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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'