Merge pull request #381 from dylanaraps/cores
Add option to hide/show hyperthreaded cpu cores.
This commit is contained in:
commit
6a37a9bb11
|
@ -364,7 +364,9 @@ alias neofetch2="neofetch \
|
||||||
NOTE: This only support Linux with cpufreq.
|
NOTE: This only support Linux with cpufreq.
|
||||||
--cpu_shorthand type Shorten the output of CPU
|
--cpu_shorthand type Shorten the output of CPU
|
||||||
Possible values: name, speed, tiny, on, off
|
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)
|
--distro_shorthand on/off Shorten the output of distro (tiny, on, off)
|
||||||
NOTE: This is only possible on Linux, macOS, and Solaris
|
NOTE: This is only possible on Linux, macOS, and Solaris
|
||||||
--kernel_shorthand on/off Shorten the output of kernel
|
--kernel_shorthand on/off Shorten the output of kernel
|
||||||
|
|
|
@ -108,8 +108,11 @@ cpu_display="off"
|
||||||
|
|
||||||
# CPU Cores
|
# CPU Cores
|
||||||
# Display CPU cores in output
|
# Display CPU cores in output
|
||||||
# --cpu_cores on/off
|
# Logical: All virtual cores
|
||||||
cpu_cores="on"
|
# Physical: All physical cores
|
||||||
|
# --cpu_cores logical, physical, off
|
||||||
|
# Note: 'physical' doesn't work on BSD.
|
||||||
|
cpu_cores="logical"
|
||||||
|
|
||||||
|
|
||||||
# GPU
|
# GPU
|
||||||
|
|
26
neofetch
26
neofetch
|
@ -724,7 +724,11 @@ getcpu() {
|
||||||
speed="$((speed / 100))"
|
speed="$((speed / 100))"
|
||||||
fi
|
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
|
# Fix for speeds under 1ghz
|
||||||
if [ -z "${speed:1}" ]; then
|
if [ -z "${speed:1}" ]; then
|
||||||
|
@ -738,7 +742,12 @@ getcpu() {
|
||||||
|
|
||||||
"Mac OS X")
|
"Mac OS X")
|
||||||
cpu="$(sysctl -n machdep.cpu.brand_string)"
|
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")
|
"iPhone OS")
|
||||||
|
@ -884,8 +893,11 @@ getcpu() {
|
||||||
speed="$(psrinfo -v | awk '/operates at/ {print $6}')"
|
speed="$(psrinfo -v | awk '/operates at/ {print $6}')"
|
||||||
speed="$((speed / 100))"
|
speed="$((speed / 100))"
|
||||||
|
|
||||||
# Get cpu cores
|
# Show/hide hyperthreaded cores
|
||||||
cores="$(kstat -m cpu_info | grep -c "chip_id")"
|
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
|
# Fix for speeds under 1ghz
|
||||||
if [ -z "${speed:1}" ]; then
|
if [ -z "${speed:1}" ]; then
|
||||||
|
@ -913,7 +925,7 @@ getcpu() {
|
||||||
cpu="${cpu//with Radeon HD Graphics}"
|
cpu="${cpu//with Radeon HD Graphics}"
|
||||||
|
|
||||||
# Add cpu cores to output
|
# Add cpu cores to output
|
||||||
[ "$cpu_cores" == "on" ] && [ "$cores" ] && \
|
[ "$cpu_cores" != "off" ] && [ "$cores" ] && \
|
||||||
cpu="${cpu/@/(${cores}) @}"
|
cpu="${cpu/@/(${cores}) @}"
|
||||||
|
|
||||||
# Make the output of cpu shorter
|
# Make the output of cpu shorter
|
||||||
|
@ -2948,7 +2960,9 @@ usage() { cat << EOF
|
||||||
NOTE: This only support Linux with cpufreq.
|
NOTE: This only support Linux with cpufreq.
|
||||||
--cpu_shorthand type Shorten the output of CPU
|
--cpu_shorthand type Shorten the output of CPU
|
||||||
Possible values: name, speed, tiny, on, off
|
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)
|
--distro_shorthand on/off Shorten the output of distro (tiny, on, off)
|
||||||
NOTE: This is only possible on Linux, macOS, and Solaris
|
NOTE: This is only possible on Linux, macOS, and Solaris
|
||||||
--kernel_shorthand on/off Shorten the output of kernel
|
--kernel_shorthand on/off Shorten the output of kernel
|
||||||
|
|
|
@ -35,8 +35,10 @@ Shorten the output of CPU
|
||||||
.br
|
.br
|
||||||
Possible values: name, speed, tiny, on, off
|
Possible values: name, speed, tiny, on, off
|
||||||
.TP
|
.TP
|
||||||
.B \--cpu_cores 'on/off'
|
.B \--cpu_cores 'logical/physical/off'
|
||||||
Whether or not to display the number of CPU cores
|
Whether or not to display the number of CPU cores
|
||||||
|
.br
|
||||||
|
Note: 'physical' doesn't work on BSD.
|
||||||
.TP
|
.TP
|
||||||
.B \--distro_shorthand 'on/off'
|
.B \--distro_shorthand 'on/off'
|
||||||
Shorten the output of distro (tiny, on, off)
|
Shorten the output of distro (tiny, on, off)
|
||||||
|
@ -51,7 +53,8 @@ Shorten the output of uptime (tiny, on, off)
|
||||||
.TP
|
.TP
|
||||||
.B \--refresh_rate 'on/off'
|
.B \--refresh_rate 'on/off'
|
||||||
Whether to display the refresh rate of each monitor
|
Whether to display the refresh rate of each monitor
|
||||||
Unsupported on Windows
|
.br
|
||||||
|
Note: Unsupported on Windows
|
||||||
.TP
|
.TP
|
||||||
.B \--gpu_shorthand 'on/off'
|
.B \--gpu_shorthand 'on/off'
|
||||||
Shorten the output of GPU (tiny, on, off)
|
Shorten the output of GPU (tiny, on, off)
|
||||||
|
|
Reference in New Issue