Pangram verdict · v3.3
We believe that this document is fully human-written
AI likelihood · overall
HumanArticle text · 447 words · 5 segments analyzed
#!/bin/bash set -Efeuxo pipefail
APP="Unlag Neo" DISPLAY_NAME="Unlag Neo"
if [ -e "${APP}.app" ]; then echo "Error: ${APP}.app exists already" exit 1 fi
mkdir -vp "${APP}.app/Contents/MacOS" "${APP}.app/Contents/Resources" PATH="$PATH:/usr/libexec"
swiftc - -o "${APP}.app/Contents/MacOS/${APP}" <<'SWIFT' import Foundation import AppKit import CoreGraphics import CoreMedia import ServiceManagement import ApplicationServices @preconcurrency import ScreenCaptureKit struct CaptureError: Error, CustomStringConvertible { let description: String init(_ description: String) { self.description = description } } @MainActor var showedPermissionAlert = false @MainActor var showedAccessibilityAlert = false @MainActor func relaunchUnlag() { let isApp = Bundle.main.bundlePath.hasSuffix(".app") let target = isApp ? Bundle.main.bundlePath : (Bundle.main.executablePath ??
Bundle.main.bundlePath) let p = Process() p.executableURL = URL(fileURLWithPath: "/bin/sh") p.arguments = ["-c", isApp ? "sleep 0.5; /usr/bin/open \"$1\"" : "sleep 0.5; \"$1\" >/dev/null 2>&1 &", "sh", target] try? p.run() NSApp.terminate(nil) } @MainActor func openScreenRecordingSettings() { NSWorkspace.shared.open(URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture")!) } @MainActor func openAccessibilitySettings() { NSWorkspace.shared.open(URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")!) } @MainActor func showPermissionAlert() { NSApp.activate(ignoringOtherApps: true) let a = NSAlert() a.alertStyle = .warning a.messageText = "Screen Recording Permission Needed" a.informativeText = "Give Screen Recording permission in System Settings, then restart Unlag Neo."
a.addButton(withTitle: "Open Settings") a.addButton(withTitle: "Restart Unlag Neo") a.addButton(withTitle: "Quit Unlag Neo") switch a.runModal() { case .alertFirstButtonReturn: openScreenRecordingSettings() let b = NSAlert() b.alertStyle = .informational b.messageText = "Restart Unlag Neo After Permission" b.informativeText = "After enabling Screen Recording permission, restart Unlag Neo." b.addButton(withTitle: "Restart Unlag Neo") b.addButton(withTitle: "Quit Unlag Neo") if b.runModal() == .alertFirstButtonReturn { relaunchUnlag() } else { NSApp.terminate(nil) } case .alertSecondButtonReturn: relaunchUnlag() default: NSApp.terminate(nil) } } @MainActor func showAccessibilityAlert() { guard !
showedAccessibilityAlert else { return } showedAccessibilityAlert = true NSApp.activate(ignoringOtherApps: true) let a = NSAlert() a.alertStyle = .warning a.messageText = "Accessibility Permission Needed" a.informativeText = "Give Accessibility permission in System Settings, then restart Unlag Neo." a.addButton(withTitle: "Open Settings") a.addButton(withTitle: "Restart Unlag Neo") a.addButton(withTitle: "Quit Unlag Neo") switch a.runModal() { case .alertFirstButtonReturn: openAccessibilitySettings() let b = NSAlert() b.alertStyle = .informational b.messageText = "Restart Unlag Neo After Permission" b.informativeText = "After enabling Accessibility permission, restart Unlag Neo." b.addButton(withTitle: "Restart Unlag Neo") b.addButton(withTitle: "Quit Unlag Neo") if b.runModal() == .alertFirstButtonReturn { relaunchUnlag() } else { NSApp.terminate(nil) }
case .alertSecondButtonReturn: relaunchUnlag() default: NSApp.terminate(nil) } } @MainActor func requireScreenRecordingPermission() throws { guard !CGPreflightScreenCaptureAccess() else { return } _ = CGRequestScreenCaptureAccess() if !showedPermissionAlert { showedPermissionAlert = true showPermissionAlert() } throw CaptureError("Missing Screen Recording permission.") } func axCopy(_ element: AXUIElement, _ attr: String) -> AnyObject? { var value: CFTypeRef? return AXUIElementCopyAttributeValue(element, attr as CFString, &value) == .success ? value : nil } func axBool(_ element: AXUIElement, _ attr: String) -> Bool { (axCopy(element, attr) as? NSNumber)?.boolValue ?? false } func axValue(_ element: AXUIElement, _ attr: String, _ type: AXValueType) -> AXValue? { guard let v = axCopy(element, attr) else { return nil } let axv = v as! AXValue return AXValueGetType(axv) == type ?