start out updating macos

This commit is contained in:
Mars 2025-01-29 17:08:40 -05:00
parent ff3d9bcce8
commit 5f2ecf8cae
Signed by: pupbrained
GPG key ID: 874E22DF2F9DFCB5
4 changed files with 31 additions and 3 deletions

View file

@ -1,6 +1,8 @@
#ifdef __APPLE__
#include <map>
#include <sys/sysctl.h>
#include <sys/utsname.h>
#include "macos/bridge.h"
#include "os.h"
@ -25,4 +27,29 @@ fn GetOSVersion() -> string { return GetMacOSVersion(); }
fn GetDesktopEnvironment() -> string { return "Aqua"; }
fn GetKernelVersion() -> string {
struct utsname uts;
if (uname(&uts) == -1) {
ERROR_LOG("uname() failed: {}", std::strerror(errno));
return "";
}
return static_cast<const char*>(uts.release);
}
fn GetHost() -> string {
std::array<char, 256> hwModel;
size_t hwModelLen = sizeof(hwModel);
sysctlbyname("hw.model", hwModel.data(), &hwModelLen, nullptr, 0);
// shamelessly stolen from https://github.com/fastfetch-cli/fastfetch/blob/dev/src/detection/host/host_mac.c
std::map<string, string> modelNameByHwModel = {
{ "Mac14,2", "MacBook Air (M2, 2022)" }
};
return modelNameByHwModel[hwModel.data()];
}
#endif