summaryrefslogtreecommitdiffstats
path: root/src/detection/wmtheme/wmtheme_apple.m
diff options
context:
space:
mode:
authorsumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
committersumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
commit76424950e373d3b04ac3dd13019151bfba3e8423 (patch)
tree4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/detection/wmtheme/wmtheme_apple.m
Add the files
Diffstat (limited to 'src/detection/wmtheme/wmtheme_apple.m')
-rw-r--r--src/detection/wmtheme/wmtheme_apple.m40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/detection/wmtheme/wmtheme_apple.m b/src/detection/wmtheme/wmtheme_apple.m
new file mode 100644
index 0000000..8c43877
--- /dev/null
+++ b/src/detection/wmtheme/wmtheme_apple.m
@@ -0,0 +1,40 @@
+#include "fastfetch.h"
+#include "wmtheme.h"
+
+#import <Foundation/Foundation.h>
+
+bool ffDetectWmTheme(FFstrbuf* themeOrError)
+{
+ NSError* error;
+ NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/.GlobalPreferences.plist", instance.state.platform.homeDir.chars];
+ NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName]
+ error:&error];
+ if(error)
+ {
+ ffStrbufAppendS(themeOrError, error.localizedDescription.UTF8String);
+ return false;
+ }
+
+ NSNumber* wmThemeColor = dict[@"AppleAccentColor"];
+ if(!wmThemeColor)
+ ffStrbufAppendS(themeOrError, "Multicolor");
+ else
+ {
+ switch(wmThemeColor.intValue)
+ {
+ case -1: ffStrbufAppendS(themeOrError, "Graphite"); break;
+ case 0: ffStrbufAppendS(themeOrError, "Red"); break;
+ case 1: ffStrbufAppendS(themeOrError, "Orange"); break;
+ case 2: ffStrbufAppendS(themeOrError, "Yellow"); break;
+ case 3: ffStrbufAppendS(themeOrError, "Green"); break;
+ case 4: ffStrbufAppendS(themeOrError, "Blue"); break;
+ case 5: ffStrbufAppendS(themeOrError, "Purple"); break;
+ case 6: ffStrbufAppendS(themeOrError, "Pink"); break;
+ default: ffStrbufAppendS(themeOrError, "Unknown"); break;
+ }
+ }
+
+ NSString* wmTheme = dict[@"AppleInterfaceStyle"];
+ ffStrbufAppendF(themeOrError, " (%s)", wmTheme ? wmTheme.UTF8String : "Light");
+ return true;
+}