From 7caa8d461801432e5e9463ee7f8ba82f4a2ccfc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 27 Sep 2023 15:03:28 +0800 Subject: [PATCH] CPU (Linux): try detecting CPU name using `lscpu` Fix #567 --- CHANGELOG.md | 1 + src/detection/cpu/cpu_linux.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0fdfceb1..796421cf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ Features: * Support Windows Service Pack version detection (Kernel, Windows) * Support Debian point releases detection (OS, Linux) * Add new module `NetIO` which prints network throughput (usage) of specified interface. Note this module costs about 1 second to finish. +* Use `lscpu` to detect CPU name for ARM CPUs (CPU, Linux) Bugfixes: * Fix fastfetch hanging in specific environment (#561) diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index af340756b..1243fbf78 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -1,5 +1,6 @@ #include "cpu.h" #include "common/io/io.h" +#include "common/processing.h" #include "common/properties.h" #include "detection/temps/temps_linux.h" #include "util/mallocHelper.h" @@ -50,6 +51,16 @@ static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, ); } + if (cpu->name.length == 0) + { + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); + if (!ffProcessAppendStdOut(&buffer, (char *const[]) { "lscpu", NULL })) + { + ffParsePropLines(buffer.chars, "Model name:", &cpu->name); + if (ffStrbufEqualS(&cpu->name, "-")) ffStrbufClear(&cpu->name); + } + } + return NULL; }