[PR] dylanaraps/neofetch#2038 from GustavoSilvera - Improving MacOS M1 CPU/GPU prints

Upstream PR: https://github.com/dylanaraps/neofetch/pull/2038
Thanks to @GustavoSilvera

Co-authored-by: Gustavo Silvera <grs5382@gmail.com>
This commit is contained in:
Azalea (on HyDEV-Daisy) 2022-07-31 15:31:30 -04:00
commit 54dbc35c2d

View file

@ -2544,7 +2544,13 @@ get_cpu() {
# Add CPU cores to the output. # Add CPU cores to the output.
[[ "$cpu_cores" != "off" && "$cores" ]] && \ [[ "$cpu_cores" != "off" && "$cores" ]] && \
case $os in case $os in
"Mac OS X"|"macOS") cpu="${cpu/@/(${cores}) @}" ;; "Mac OS X"|"macOS")
if [[ $(uname -m) == 'arm64' ]]; then
cpu="$cpu ($cores)"
else
cpu="${cpu/@/(${cores}) @}"
fi
;;
*) cpu="$cpu ($cores)" ;; *) cpu="$cpu ($cores)" ;;
esac esac
@ -2663,11 +2669,17 @@ get_gpu() {
if [[ -f "${cache_dir}/neofetch/gpu" ]]; then if [[ -f "${cache_dir}/neofetch/gpu" ]]; then
source "${cache_dir}/neofetch/gpu" source "${cache_dir}/neofetch/gpu"
else
if [[ $(uname -m) == 'arm64' ]]; then
chipset=$(system_profiler SPDisplaysDataType | awk '/Chipset Model/ { printf "%s %s %s", $3, $4, $5 }')
cores=$(system_profiler SPDisplaysDataType | awk '/Total Number of Cores/ { printf "%d", $5 }')
gpu="${chipset} (${cores})"
else else
gpu="$(system_profiler SPDisplaysDataType |\ gpu="$(system_profiler SPDisplaysDataType |\
awk -F': ' '/^\ *Chipset Model:/ {printf $2 ", "}')" awk -F': ' '/^\ *Chipset Model:/ {printf $2 ", "}')"
gpu="${gpu//\/ \$}" gpu="${gpu//\/ \$}"
gpu="${gpu%,*}" gpu="${gpu%,*}"
fi
cache "gpu" "$gpu" cache "gpu" "$gpu"
fi fi