ncneofetch: use kern.osproductversion sysctl for macOS version #2158

pull/2159/head
nick black 3 years ago
parent 54cf38b076
commit 5734444d49

@ -347,6 +347,7 @@ dragonfly_ncneofetch(fetched_info* fi){
return &fbsd;
}
#ifdef __APPLE__
static const distro_info*
xnu_ncneofetch(fetched_info* fi){
static distro_info fbsd = {
@ -354,9 +355,17 @@ xnu_ncneofetch(fetched_info* fi){
.logofile = "/System/Library/PrivateFrameworks/LoginUIKit.framework/Versions/A/Frameworks/LoginUICore.framework/Versions/A/Resources/apple@2x.png",
};
fi->neologo = get_neofetch_art("Darwin");
fi->distro_pretty = strdup("OS X 11.4 (Big Sur)"); // FIXME
#define PREFIX "macOS "
char osver[30] = PREFIX; // shrug
size_t oldlenp = sizeof(osver) - strlen(PREFIX);
if(sysctlbyname("kern.osproductversion", osver + strlen(PREFIX),
&oldlenp, NULL, 0) == 0){
fi->distro_pretty = strdup(osver);
}
#undef PREFIX
return &fbsd;
}
#endif
static int
drawpalette(struct notcurses* nc){
@ -622,9 +631,11 @@ ncneofetch(struct notcurses* nc){
case NCNEO_DRAGONFLY:
fi.distro = dragonfly_ncneofetch(&fi);
break;
#ifdef __APPLE__
case NCNEO_XNU:
fi.distro = xnu_ncneofetch(&fi);
break;
#endif
case NCNEO_WINDOWS:
fi.distro = windows_ncneofetch(&fi);
break;

Loading…
Cancel
Save