Skip to content

Commit

Permalink
[F] Fix CPU detection for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
hykilpikonna committed Jul 31, 2022
1 parent ce5e7f1 commit 42d6aa4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions neofetch
Original file line number Diff line number Diff line change
Expand Up @@ -2237,9 +2237,17 @@ get_cpu() {
;;

"arm"* | "aarch64")
cpu="$(lscpu | awk -F': ' '/Vendor ID/ {print $2; exit}' ) $(lscpu | awk -F': ' '/Model name/ {print $2; exit}')"
if [[ $(trim "$ascii_distro") == Android* ]]; then
# Android roms have modified cpuinfo that shows CPU model as a string
cpu="$(awk -F '\\s*: | @' \
'/model name|Hardware|Processor|^cpu model|chip type|^cpu type/ {
cpu=$2; if ($1 == "Hardware") exit } END { print cpu }' "$cpu_file")"
else
# ARM linux displays binary model code in cpuinfo, which needs to be decoded with lscpu
cpu="$(lscpu | awk -F': ' '/Vendor ID/ {print $2; exit}') $(lscpu | awk -F': ' '/Model name/ {print $2; exit}')"
fi
;;

"riscv"*)
cpu="$(awk -F': ' '/uarch/ {print $2; exit}' "$cpu_file")"
;;
Expand Down

0 comments on commit 42d6aa4

Please sign in to comment.