Skip to content

Commit

Permalink
CPU (Linux): try detecting CPU name using lscpu
Browse files Browse the repository at this point in the history
Fix #567
  • Loading branch information
CarterLi committed Sep 27, 2023
1 parent 88c1248 commit 7caa8d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions src/detection/cpu/cpu_linux.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 7caa8d4

Please sign in to comment.