mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
osascript: simplify code (macOS)
This commit is contained in:
@@ -4,14 +4,14 @@
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <CoreData/CoreData.h>
|
||||
|
||||
bool ffOsascript(const char* input, FFstrbuf* result) {
|
||||
NSString* appleScript = [NSString stringWithUTF8String: input];
|
||||
NSAppleScript* script = [[NSAppleScript alloc] initWithSource:appleScript];
|
||||
bool ffOsascript(const char* input, FFstrbuf* result)
|
||||
{
|
||||
NSAppleScript* script = [NSAppleScript.alloc initWithSource:@(input)];
|
||||
NSDictionary* errInfo = nil;
|
||||
NSAppleEventDescriptor* descriptor = [script executeAndReturnError:&errInfo];
|
||||
if (errInfo)
|
||||
return false;
|
||||
|
||||
ffStrbufSetS(result, [[descriptor stringValue] cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
ffStrbufSetS(result, descriptor.stringValue.UTF8String);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user