Skip to content

Commit 89e4403

Browse files
committed
WM (macOS): add WindowServer version detection
1 parent c68d21e commit 89e4403

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ elseif(APPLE)
922922
src/detection/users/users_linux.c
923923
src/detection/wallpaper/wallpaper_apple.m
924924
src/detection/wifi/wifi_apple.m
925-
src/detection/wm/wm_apple.c
925+
src/detection/wm/wm_apple.m
926926
src/detection/de/de_nosupport.c
927927
src/detection/wmtheme/wmtheme_apple.m
928928
src/detection/camera/camera_apple.m

src/detection/wm/wm_apple.c renamed to src/detection/wm/wm_apple.m

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "util/stringUtils.h"
66

77
#include <ctype.h>
8+
#import <Foundation/Foundation.h>
89

910
const char* ffDetectWMPlugin(FFstrbuf* pluginName)
1011
{
@@ -39,7 +40,18 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName)
3940
return NULL;
4041
}
4142

42-
const char* ffDetectWMVersion(FF_MAYBE_UNUSED const FFstrbuf* wmName, FF_MAYBE_UNUSED FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options)
43+
const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options)
4344
{
44-
return "Not supported on this platform";
45+
if (!wmName)
46+
return "No WM detected";
47+
48+
if (ffStrbufEqualS(wmName, "WindowServer"))
49+
{
50+
NSError* error;
51+
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:@"file:///System/Library/CoreServices/WindowManager.app/Contents/version.plist"]
52+
error:&error];
53+
ffStrbufInitS(result, ((NSString*) dict[@"CFBundleVersion"]).UTF8String);
54+
}
55+
56+
return NULL;
4557
}

0 commit comments

Comments
 (0)