2021-02-18 22:25:36 +01:00
|
|
|
#include "fastfetch.h"
|
|
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
void ffPrintHost(FFinstance* instance)
|
2021-02-18 22:25:36 +01:00
|
|
|
{
|
2021-02-27 18:30:05 +01:00
|
|
|
if(ffPrintCachedValue(instance, "Host"))
|
2021-02-22 16:52:51 +01:00
|
|
|
return;
|
|
|
|
|
|
2021-03-07 11:58:24 +01:00
|
|
|
char host[256];
|
|
|
|
|
ffGetFileContent("/sys/devices/virtual/dmi/id/product_name", host, sizeof(host) - 32); //We subtract 32 to have at least this padding for the version
|
|
|
|
|
if(host[0] == '\0')
|
2021-02-19 16:23:41 +01:00
|
|
|
{
|
2021-03-07 11:58:24 +01:00
|
|
|
ffPrintError(instance, "Host", "ffGetFileContent(\"/sys/devices/virtual/dmi/id/product_name\", host, sizeof(host)) failed");
|
2021-02-19 16:23:41 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2021-02-18 22:25:36 +01:00
|
|
|
|
2021-03-07 11:58:24 +01:00
|
|
|
if(instance->config.hostShowVersion)
|
2021-02-19 16:23:41 +01:00
|
|
|
{
|
2021-03-07 11:58:24 +01:00
|
|
|
size_t len = strlen(host);
|
|
|
|
|
host[len++] = ' ';
|
|
|
|
|
ffGetFileContent("/sys/devices/virtual/dmi/id/product_version", host + len, sizeof(host) - len);
|
2021-02-19 16:23:41 +01:00
|
|
|
}
|
2021-02-22 16:52:51 +01:00
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
ffPrintAndSaveCachedValue(instance, "Host", host);
|
2021-02-18 22:25:36 +01:00
|
|
|
}
|