Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233import CoreGraphicsimport Foundation
struct E2EConsoleSession: Decodable { static let unavailableMessage = "Required e2e cannot run: sign in, unlock this Mac's screen, and keep the desktop session active before rerunning make e2e."
let onConsole: Bool let loginDone: Bool let screenLocked: Bool?
private enum CodingKeys: String, CodingKey { case onConsole = "kCGSSessionOnConsoleKey" case loginDone = "kCGSessionLoginDoneKey" case screenLocked = "CGSSessionScreenIsLocked" }
static func requireUnlockedConsole() throws { guard let dictionary = CGSessionCopyCurrentDictionary() else { throw E2EError(description: unavailableMessage) } let data = try PropertyListSerialization.data(fromPropertyList: dictionary, format: .binary, options: 0) try PropertyListDecoder().decode(Self.self, from: data).requireUnlocked() }
func requireUnlocked() throws { // The lock marker is absent in an unlocked session. guard onConsole, loginDone, screenLocked != true else { throw E2EError(description: Self.unavailableMessage) } }}