mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
OS (macOS): improves OS detection accuracy and sets pretty name
This commit is contained in:
@@ -8,14 +8,14 @@
|
||||
#include <string.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
static void parseSystemVersion(FFOSResult* os)
|
||||
static bool parseSystemVersion(FFOSResult* os)
|
||||
{
|
||||
NSError* error;
|
||||
NSString* fileName = @"file:///System/Library/CoreServices/SystemVersion.plist";
|
||||
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName]
|
||||
error:&error];
|
||||
if(error)
|
||||
return;
|
||||
return false;
|
||||
|
||||
NSString* value;
|
||||
|
||||
@@ -30,6 +30,8 @@ static void parseSystemVersion(FFOSResult* os)
|
||||
// macOS 26 Tahoe. #1809
|
||||
os->version.chars[0] = '2';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool detectOSCodeName(FFOSResult* os)
|
||||
@@ -86,13 +88,18 @@ void ffDetectOSImpl(FFOSResult* os)
|
||||
|
||||
ffStrbufSetStatic(&os->id, "macos");
|
||||
|
||||
if(os->version.length == 0)
|
||||
if(__builtin_expect(os->name.length == 0, 0))
|
||||
ffStrbufSetStatic(&os->name, "macOS");
|
||||
|
||||
if(__builtin_expect(os->version.length == 0, 0))
|
||||
ffSysctlGetString("kern.osproductversion", &os->version);
|
||||
|
||||
if(os->buildID.length == 0)
|
||||
if(__builtin_expect(os->buildID.length == 0, 0))
|
||||
ffSysctlGetString("kern.osversion", &os->buildID);
|
||||
|
||||
ffStrbufAppend(&os->versionID, &os->version);
|
||||
|
||||
detectOSCodeName(os);
|
||||
|
||||
ffStrbufSetF(&os->prettyName, "%s %s %s (%s)", os->name.chars, os->codename.chars, os->version.chars, os->buildID.chars);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user