mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-28 15:44:32 +00:00
Restored files from old Mac, force pushing
This commit is contained in:
parent
5dd95228b8
commit
5040381840
126 changed files with 10431 additions and 67 deletions
31
DynamicIsland/helpers/AppleScriptHelper.swift
Normal file
31
DynamicIsland/helpers/AppleScriptHelper.swift
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// AppleScriptHelper.swift
|
||||
// boringNotch
|
||||
//
|
||||
// Created by Alexander Greco on 2025-03-29.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class AppleScriptHelper {
|
||||
@discardableResult
|
||||
class func execute(_ scriptText: String) async throws -> NSAppleEventDescriptor? {
|
||||
try await withCheckedThrowingContinuation { continuation in
|
||||
Task.detached(priority: .userInitiated) {
|
||||
let script = NSAppleScript(source: scriptText)
|
||||
var error: NSDictionary?
|
||||
if let descriptor = script?.executeAndReturnError(&error) {
|
||||
continuation.resume(returning: descriptor)
|
||||
} else if let error = error {
|
||||
continuation.resume(throwing: NSError(domain: "AppleScriptError", code: 1, userInfo: error as? [String: Any]))
|
||||
} else {
|
||||
continuation.resume(throwing: NSError(domain: "AppleScriptError", code: 1, userInfo: [NSLocalizedDescriptionKey: "Unknown error"]))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class func executeVoid(_ scriptText: String) async throws {
|
||||
_ = try await execute(scriptText)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue