From 0fdd3b8637baf25841ca4378908145e1542e1992 Mon Sep 17 00:00:00 2001 From: Herdiansyah Date: Thu, 15 Dec 2016 18:03:10 +0700 Subject: [PATCH] CPU [Linux]: Added CPU name detection for more architectures (#529) This fixes #526. --- CHANGELOG.md | 4 ++++ neofetch | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3fc5fcf..c6d19380 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,10 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques - [Fish] Fixed memory leak caused by Fish. +**CPU**
+ +- [Linux] Fixed issues with CPU name detection for architectures other than x86/amd64/ARM. + **Desktop Environment**
- Fixed issues where MATE wouldn't be detected properly. diff --git a/neofetch b/neofetch index f2d34bd0..4bc606ac 100755 --- a/neofetch +++ b/neofetch @@ -734,7 +734,23 @@ get_cpu() { # Get CPU name case "$distro" in "Android"*) cpu="$(getprop ro.product.board)" ;; - *) cpu="$(awk -F ': | @' '/model name|Processor/ {printf $2; exit}' /proc/cpuinfo)" ;; + *) + case "$machine_arch" in + "frv" | "hppa" | "m68k" | "openrisc" | "or"* | "powerpc" | "ppc"* | "sparc"*) + cpu="$(awk -F':' '/^cpu\t|^CPU/ {printf $2; exit}' /proc/cpuinfo)" + ;; + "s390"*) + cpu="$(awk -F'=' '/machine/ {print $4; exit}' /proc/cpuinfo)" + ;; + "ia64" | "m32r") + cpu="$(awk -F':' '/model/ {print $2; exit}' /proc/cpuinfo)" + [[ -z "$cpu" ]] && cpu="$(awk -F':' '/family/ {printf $2; exit}' /proc/cpuinfo)" + ;; + *) + cpu="$(awk -F ': | @' '/model name|Processor|^cpu model|chip type|^cpu type/ {printf $2; exit}' /proc/cpuinfo)" + ;; + esac + ;; esac speed_dir="/sys/devices/system/cpu/cpu0/cpufreq" @@ -888,6 +904,7 @@ get_cpu() { cpu="${cpu//Eight-Core}" cpu="${cpu//Core}" cpu="${cpu//with Radeon * Graphics}" + cpu="${cpu//, altivec supported}" # Add cpu cores to output [[ "$cpu_cores" != "off" && "$cores" ]] && \