Fixed cpu name (openbsd)
This commit is contained in:
parent
3b3624f110
commit
cb3db2e634
1 changed files with 9 additions and 5 deletions
12
uwufetch.c
12
uwufetch.c
|
@ -942,7 +942,7 @@ struct info get_info()
|
||||||
#ifndef __BSD__
|
#ifndef __BSD__
|
||||||
FILE* cpuinfo = fopen("/proc/cpuinfo", "r"); // cpu name file for not-freebsd systems
|
FILE* cpuinfo = fopen("/proc/cpuinfo", "r"); // cpu name file for not-freebsd systems
|
||||||
#else
|
#else
|
||||||
FILE* cpuinfo = popen("sysctl -a | egrep -i 'hw.model'", "r"); // cpu name command for freebsd
|
FILE* cpuinfo = popen("sysctl 'hw.model'", "r"); // cpu name command for freebsd
|
||||||
#endif
|
#endif
|
||||||
// trying to get some kind of information about the name of the computer (hopefully a product full name)
|
// trying to get some kind of information about the name of the computer (hopefully a product full name)
|
||||||
FILE* model_fp /* = fopen("/sys/devices/virtual/dmi/id/product_version", "r") */; // trying to get product version
|
FILE* model_fp /* = fopen("/sys/devices/virtual/dmi/id/product_version", "r") */; // trying to get product version
|
||||||
|
@ -983,14 +983,18 @@ struct info get_info()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(__BSD__) || defined(__APPLE__)
|
#elif defined(__BSD__) || defined(__APPLE__)
|
||||||
#if defined(__BSD__)
|
#if defined(__BSD__) && !defined(__OPENBSD__)
|
||||||
#define HOSTCTL "hw.hv_vendor"
|
#define HOSTCTL "hw.hv_vendor"
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__) || defined(__OPENBSD__)
|
||||||
#define HOSTCTL "hw.model"
|
#define HOSTCTL "hw.model"
|
||||||
#endif
|
#endif
|
||||||
model_fp = popen("sysctl -a " HOSTCTL, "r");
|
model_fp = popen("sysctl " HOSTCTL, "r");
|
||||||
while (fgets(buffer, sizeof(buffer), model_fp))
|
while (fgets(buffer, sizeof(buffer), model_fp))
|
||||||
|
#if defined(__FREEBSD__) || defined(__APPLE__)
|
||||||
if (sscanf(buffer, HOSTCTL ": %[^\n]", user_info.model)) break;
|
if (sscanf(buffer, HOSTCTL ": %[^\n]", user_info.model)) break;
|
||||||
|
#elif defined(__OPENBSD__)
|
||||||
|
if (sscanf(buffer, HOSTCTL "=%[^\n]", user_info.model)) break;
|
||||||
|
#endif
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
if (os_release) { // get normal vars if os_release exists
|
if (os_release) { // get normal vars if os_release exists
|
||||||
while (fgets(buffer, sizeof(buffer), os_release) && !(sscanf(buffer, "\nID=\"%s\"", user_info.os_name) || sscanf(buffer, "\nID=%s", user_info.os_name)))
|
while (fgets(buffer, sizeof(buffer), os_release) && !(sscanf(buffer, "\nID=\"%s\"", user_info.os_name) || sscanf(buffer, "\nID=%s", user_info.os_name)))
|
||||||
|
|
Loading…
Reference in a new issue