Files
fastfetch/src/host.c
T

34 lines
917 B
C
Raw Normal View History

2021-02-18 22:25:36 +01:00
#include "fastfetch.h"
void ffPrintHost(FFstate* state)
{
2021-02-19 16:23:41 +01:00
FILE* nameFile = fopen("/sys/devices/virtual/dmi/id/product_name", "r");
if(nameFile == NULL)
{
if(state->showErrors)
ffPrintError(state, "Host", "fopen(\"/sys/devices/virtual/dmi/id/product_name\", \"r\") == NULL");
return;
}
2021-02-18 22:25:36 +01:00
char name[256];
2021-02-19 16:23:41 +01:00
if(fscanf(nameFile, "%[^\n]", name) != 1)
{
if(state->showErrors)
ffPrintError(state, "Host", "fscanf(nameFile, \"%[^\\n]\", name) != 1");
return;
}
fclose(nameFile);
2021-02-18 22:25:36 +01:00
ffPrintLogoAndKey(state, "Host");
2021-02-19 16:23:41 +01:00
printf(name);
FILE* versionFile = fopen("/sys/devices/virtual/dmi/id/product_version", "r");
if(versionFile != NULL)
{
char version[256];
if(fscanf(versionFile, "%[^\n]", version) == 1)
printf(" %s", version);
fclose(versionFile);
}
putchar('\n');
2021-02-18 22:25:36 +01:00
}