From 2f3afce434ee514ae6871b9089753c80a03a58e4 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Fri, 7 Aug 2026 03:18:08 +0000 Subject: [PATCH 37/38] wm (Apple): stub out plugin/version detection before macOS 10.5 libproc.h/proc_pidpath and the sysctl-based process walk aren't usable pre-10.5; return "Not supported on this platform" on those targets, and switch the WindowServer version plist lookup to the non-ARC-only API. Ported from https://github.com/macos-powerpc/powerpc-ports/blob/main/sysutils/fastfetch/files/0013-wm_apple-unbreak.patch --- src/detection/wm/wm_apple.m | 41 ++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/detection/wm/wm_apple.m b/src/detection/wm/wm_apple.m index c4bc780a2..6f1a91cbd 100644 --- a/src/detection/wm/wm_apple.m +++ b/src/detection/wm/wm_apple.m @@ -6,9 +6,21 @@ #include "common/apple/version.h" #include +#include +#include +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #include -#import +#endif + +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 +#define POOLSTART NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; +#define POOLEND [pool release]; +#else +#define POOLSTART +#define POOLEND +#endif +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 const char* ffDetectWMPlugin(FFstrbuf* pluginName) { int request[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL }; u_int requestLength = ARRAY_SIZE(request); @@ -70,25 +82,40 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) { return nullptr; } +#else +const char* ffDetectWMPlugin([[maybe_unused]] FFstrbuf* pluginName) +{ + return "Not supported on this platform"; +} +#endif +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, [[maybe_unused]] FFWMOptions* options) { if (!wmName) { return "No WM detected"; } if (ffStrbufEqualS(wmName, "WindowServer")) { - NSError* error; - NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL fileURLWithPath:@"/System/Library/PrivateFrameworks/SkyLight.framework/Resources/version.plist" isDirectory:NO] - error:&error]; + POOLSTART + NSDictionary* dict = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/PrivateFrameworks/SkyLight.framework/Resources/version.plist"]; + if (!dict) { - dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL fileURLWithPath:@"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/version.plist" isDirectory:NO] - error:&error]; + dict = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/version.plist"]; } if (dict) { - ffStrbufSetS(result, ((NSString*) dict[@"CFBundleShortVersionString"]).UTF8String); + NSString* versionString = [dict objectForKey:@"CFBundleShortVersionString"]; + if (versionString) + ffStrbufSetS(result, [versionString UTF8String]); } + POOLEND } return nullptr; } +#else +const char* ffDetectWMVersion([[maybe_unused]] const FFstrbuf* wmName, [[maybe_unused]] FFstrbuf* result, [[maybe_unused]] FFWMOptions* options) +{ + return "Not supported on this platform"; +} +#endif -- 2.43.0