Merge pull request #381 from dylanaraps/cores
Add option to hide/show hyperthreaded cpu cores.
This commit is contained in:
commit
6a37a9bb11
4 changed files with 33 additions and 11 deletions
26
neofetch
26
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue