Skip to content

Commit 7caa8d4

Browse files
committed
CPU (Linux): try detecting CPU name using lscpu
Fix #567
1 parent 88c1248 commit 7caa8d4

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Features:
2828
* Support Windows Service Pack version detection (Kernel, Windows)
2929
* Support Debian point releases detection (OS, Linux)
3030
* Add new module `NetIO` which prints network throughput (usage) of specified interface. Note this module costs about 1 second to finish.
31+
* Use `lscpu` to detect CPU name for ARM CPUs (CPU, Linux)
3132

3233
Bugfixes:
3334
* Fix fastfetch hanging in specific environment (#561)

src/detection/cpu/cpu_linux.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "cpu.h"
22
#include "common/io/io.h"
3+
#include "common/processing.h"
34
#include "common/properties.h"
45
#include "detection/temps/temps_linux.h"
56
#include "util/mallocHelper.h"
@@ -50,6 +51,16 @@ static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer,
5051
);
5152
}
5253

54+
if (cpu->name.length == 0)
55+
{
56+
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
57+
if (!ffProcessAppendStdOut(&buffer, (char *const[]) { "lscpu", NULL }))
58+
{
59+
ffParsePropLines(buffer.chars, "Model name:", &cpu->name);
60+
if (ffStrbufEqualS(&cpu->name, "-")) ffStrbufClear(&cpu->name);
61+
}
62+
}
63+
5364
return NULL;
5465
}
5566

0 commit comments

Comments
 (0)