From e5094a7258a9d191c0c6638963408389cf693f80 Mon Sep 17 00:00:00 2001 From: sech1p Date: Thu, 4 Nov 2021 15:33:04 +0100 Subject: [PATCH] Fix host under macOS >w< --- uwufetch.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/uwufetch.c b/uwufetch.c index 7290411..a2cc9c8 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -690,10 +690,15 @@ void get_info() break; } } -#elif defined(__FREEBSD__) - host_model_info = popen("sysctl -a hw.hv_vendor", "r"); +#elif defined(__FREEBSD__) || defined(__APPLE__) + #if defined(__FREEBSD__) + #define HOSTCTL "hw.hv_vendor" + #elif defined(__APPLE__) + #define HOSTCTL "hw.model" + #endif + host_model_info = popen("sysctl -a " HOSTCTL, "r"); while (fgets(line, sizeof(line), host_model_info)) - if (sscanf(line, "hw.hv_vendor: %[^\n]", host_model)) + if (sscanf(line, HOSTCTL ": %[^\n]", host_model)) break; #endif // __WINDOWS__ FILE *host_model_version = fopen("/sys/devices/virtual/dmi/id/product_version", "r");