mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Cursor (macOS): add support
This commit is contained in:
+1
-1
@@ -462,7 +462,7 @@ elseif(APPLE)
|
||||
src/detection/chassis/chassis_nosupport.c
|
||||
src/detection/cpu/cpu_apple.c
|
||||
src/detection/cpuUsage/cpuUsage_apple.c
|
||||
src/detection/cursor/cursor_nosupport.c
|
||||
src/detection/cursor/cursor_apple.m
|
||||
src/detection/disk/disk_apple.m
|
||||
src/detection/disk/disk_bsd.c
|
||||
src/detection/displayserver/displayserver_apple.c
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "cursor.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
static void appendColor(FFstrbuf* str, NSDictionary* color)
|
||||
{
|
||||
int r = (int) (((NSNumber*) [color valueForKey:@"red"]).doubleValue * 255);
|
||||
int g = (int) (((NSNumber*) [color valueForKey:@"green"]).doubleValue * 255);
|
||||
int b = (int) (((NSNumber*) [color valueForKey:@"blue"]).doubleValue * 255);
|
||||
int a = (int) (((NSNumber*) [color valueForKey:@"alpha"]).doubleValue * 255);
|
||||
|
||||
if (r == 255 && g == 255 && b == 255 && a == 255)
|
||||
ffStrbufAppendS(str, "White");
|
||||
else if (r == 0 && g == 0 && b == 0 && a == 255)
|
||||
ffStrbufAppendS(str, "Black");
|
||||
else
|
||||
ffStrbufAppendF(str, "#%02X%02X%02X%02X", r, g, b, a);
|
||||
}
|
||||
|
||||
void ffDetectCursor(const FFinstance* instance, FFCursorResult* result)
|
||||
{
|
||||
NSError* error;
|
||||
NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/com.apple.universalaccess.plist", instance->state.platform.homeDir.chars];
|
||||
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName]
|
||||
error:&error];
|
||||
if(error)
|
||||
{
|
||||
ffStrbufAppendS(&result->error, error.localizedDescription.UTF8String);
|
||||
return;
|
||||
}
|
||||
|
||||
NSDictionary* color;
|
||||
|
||||
ffStrbufAppendS(&result->theme, "Fill - ");
|
||||
if ((color = [dict valueForKey:@"cursorFill"]))
|
||||
appendColor(&result->theme, color);
|
||||
else
|
||||
ffStrbufAppendS(&result->theme, "Black");
|
||||
|
||||
ffStrbufAppendS(&result->theme, ", Outline - ");
|
||||
|
||||
if ((color = [dict valueForKey:@"cursorOutline"]))
|
||||
appendColor(&result->theme, color);
|
||||
else
|
||||
ffStrbufAppendS(&result->theme, "White");
|
||||
|
||||
NSNumber* mouseDriverCursorSize = [dict valueForKey:@"mouseDriverCursorSize"];
|
||||
if (mouseDriverCursorSize)
|
||||
ffStrbufAppendF(&result->size, "%d", (int) (mouseDriverCursorSize.doubleValue * 32));
|
||||
else
|
||||
ffStrbufAppendS(&result->size, "32");
|
||||
}
|
||||
Reference in New Issue
Block a user