diff --git a/whilom.xcodeproj/project.pbxproj b/whilom.xcodeproj/project.pbxproj index 54ea850..2205f79 100644 --- a/whilom.xcodeproj/project.pbxproj +++ b/whilom.xcodeproj/project.pbxproj @@ -41,11 +41,7 @@ 1E2FA93525FB12FE00D7D123 /* whilom.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = whilom.entitlements; sourceTree = ""; }; 1E396DB025FB138C008E2122 /* whilomDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = whilomDebug.entitlements; sourceTree = ""; }; 1E396DC425FB4C26008E2122 /* NSImage+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSImage+Extension.swift"; sourceTree = ""; }; - 1E5B4CFE25FB74D700092422 /* whilom-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "whilom-Bridging-Header.h"; sourceTree = ""; }; 1E5B4D0725FB779900092422 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; - 1E5B4D1025FBFA4800092422 /* ServiceManagement.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ServiceManagement.framework; path = System/Library/Frameworks/ServiceManagement.framework; sourceTree = SDKROOT; }; - 1E5B4D3925FBFC5A00092422 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 1E5B4D3B25FBFC5E00092422 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 1E5B4D6925FBFE4B00092422 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 1E5B4DD525FC0DBF00092422 /* String+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extension.swift"; sourceTree = ""; }; 1EE4E20A24F97E240097C32C /* whilom.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = whilom.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -70,9 +66,6 @@ isa = PBXGroup; children = ( 1E5B4D6925FBFE4B00092422 /* Cocoa.framework */, - 1E5B4D3B25FBFC5E00092422 /* Security.framework */, - 1E5B4D3925FBFC5A00092422 /* Foundation.framework */, - 1E5B4D1025FBFA4800092422 /* ServiceManagement.framework */, ); name = Frameworks; sourceTree = ""; @@ -100,7 +93,6 @@ 1EE4E20D24F97E240097C32C /* AppDelegate.swift */, 1E396DC425FB4C26008E2122 /* NSImage+Extension.swift */, 1E5B4DD525FC0DBF00092422 /* String+Extension.swift */, - 1E5B4CFE25FB74D700092422 /* whilom-Bridging-Header.h */, 1E396DB025FB138C008E2122 /* whilomDebug.entitlements */, 1E2FA93525FB12FE00D7D123 /* whilom.entitlements */, 1E5B4D0725FB779900092422 /* Main.storyboard */, @@ -328,8 +320,10 @@ PRODUCT_BUNDLE_IDENTIFIER = com.insanj.whilom; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OBJC_BRIDGING_HEADER = "whilom/whilom-Bridging-Header.h"; + SWIFT_INSTALL_OBJC_HEADER = NO; + SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_PRECOMPILE_BRIDGING_HEADER = YES; SWIFT_VERSION = 5.0; }; name = Debug; @@ -355,7 +349,9 @@ PRODUCT_BUNDLE_IDENTIFIER = com.insanj.whilom; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OBJC_BRIDGING_HEADER = "whilom/whilom-Bridging-Header.h"; + SWIFT_INSTALL_OBJC_HEADER = NO; + SWIFT_OBJC_BRIDGING_HEADER = ""; + SWIFT_PRECOMPILE_BRIDGING_HEADER = YES; SWIFT_VERSION = 5.0; }; name = Release; diff --git a/whilom/AppDelegate.swift b/whilom/AppDelegate.swift index adf5c94..7c7eddd 100644 --- a/whilom/AppDelegate.swift +++ b/whilom/AppDelegate.swift @@ -78,7 +78,6 @@ class AppDelegate: NSObject, NSApplicationDelegate { appendString = " user name \"\(NSUserName())\" password \"\(pass)\"" } - let myAppleScript = """ do shell script "sudo pmset -a disablesleep 0"\(shouldAppend ? appendString : "") with administrator privileges """ @@ -206,23 +205,14 @@ class AppDelegate: NSObject, NSApplicationDelegate { // MARK: execute scripts based on state @objc func disableSleep() -> Bool { if !isJustMessingAround { -// if shouldUseRememberedPassword, let remembered = rememberedPassword { -//// let result = WhilomCommand(password: remembered, type: .disableSleep).runTask() -// if let error = result.errorOutput { -// let alert = NSAlert(error: NSError(domain: "com.insanj.whilom", code: 0, userInfo: [NSLocalizedDescriptionKey: error])) -// alert.runModal() -// return false -// } -// } else { - var error: NSDictionary? - disableSleepScript?.executeAndReturnError(&error) + var error: NSDictionary? + disableSleepScript?.executeAndReturnError(&error) - if let error = error { - let alert = NSAlert(error: NSError(domain: "com.insanj.whilom", code: 0, userInfo: [NSLocalizedDescriptionKey: error["NSAppleScriptErrorMessage"]!])) - alert.runModal() - return false - } -// } + if let error = error { + let alert = NSAlert(error: NSError(domain: "com.insanj.whilom", code: 0, userInfo: [NSLocalizedDescriptionKey: error["NSAppleScriptErrorMessage"]!])) + alert.runModal() + return false + } } performSleepAnimation(forwards: true) @@ -232,23 +222,14 @@ class AppDelegate: NSObject, NSApplicationDelegate { @objc func enableSleep() -> Bool { if !isJustMessingAround { -// if shouldUseRememberedPassword, let remembered = rememberedPassword { -// let result = WhilomCommand(password: remembered, type: .enableSleep).runTask() -// if let error = result.errorOutput { -// let alert = NSAlert(error: NSError(domain: "com.insanj.whilom", code: 0, userInfo: [NSLocalizedDescriptionKey: error])) -// alert.runModal() -// return false -// } -// } else { - var error: NSDictionary? - enableSleepScript?.executeAndReturnError(&error) + var error: NSDictionary? + enableSleepScript?.executeAndReturnError(&error) - if let error = error { - let alert = NSAlert(error: NSError(domain: "com.insanj.whilom", code: 0, userInfo: [NSLocalizedDescriptionKey: error["NSAppleScriptErrorMessage"]!])) - alert.runModal() - return false - } -// } + if let error = error { + let alert = NSAlert(error: NSError(domain: "com.insanj.whilom", code: 0, userInfo: [NSLocalizedDescriptionKey: error["NSAppleScriptErrorMessage"]!])) + alert.runModal() + return false + } } performSleepAnimation(forwards: false) @@ -318,7 +299,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { imageHattieOn3 = baseHattieOne3Image } - // MARK: - perhaps temporary auth + // MARK: - perhaps temporary auth private func showPasswordRememberAlert() { let alert = NSAlert() passwordRememberAlert = alert @@ -350,6 +331,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { enableSleepScript = buildEnableSleepScript(rememberedPassword) disableSleepScript = buildDisableSleepScript(rememberedPassword) + rememberedPassword = nil } } diff --git a/whilom/Info.plist b/whilom/Info.plist index 3b1fc78..ea51a18 100644 --- a/whilom/Info.plist +++ b/whilom/Info.plist @@ -38,12 +38,5 @@ NSSupportsSuddenTermination - NSSystemAdministrationUsageDescription - Enable or disable your Mac from sleeping. - SMPrivilegedExecutables - - com.insanj.whilom.HelperTool - anchor apple generic and identifier "com.insanj.whilom.HelperTool" and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = 24X8MVUSCN) - diff --git a/whilom/NSImage+Extension.swift b/whilom/NSImage+Extension.swift index a269de1..785e689 100644 --- a/whilom/NSImage+Extension.swift +++ b/whilom/NSImage+Extension.swift @@ -5,7 +5,7 @@ // Created by Julian Weiss on 3/12/21. // Copyright © 2021 Julian Weiss. All rights reserved. // -// https://stackoverflow.com/questions/2137744/draw-standard-nsimage-inverted-white-instead-of-black +// https://stackoverflow.com/questions/2137744/draw-standard-nsimage-inverted-white-instead-of-black // import os @@ -13,7 +13,6 @@ import AppKit import Foundation public extension NSImage { - func inverted() -> NSImage { guard let cgImage = self.cgImage(forProposedRect: nil, context: nil, hints: nil) else { os_log(.error, "Could not create CGImage from NSImage") diff --git a/whilom/String+Extension.swift b/whilom/String+Extension.swift index 687903e..607e281 100644 --- a/whilom/String+Extension.swift +++ b/whilom/String+Extension.swift @@ -5,11 +5,12 @@ // Created by Julian Weiss on 3/12/21. // Copyright © 2021 Julian Weiss. All rights reserved. // +// https://stackoverflow.com/questions/52007286/show-random-emoji-inside-a-label-in-tableviewcell +// import Foundation extension String { - // https://stackoverflow.com/questions/52007286/show-random-emoji-inside-a-label-in-tableviewcell static var randomEmoji: String? { guard let randomElement = Array(0x1F300...0x1F3F0).randomElement() else { return nil diff --git a/whilom/whilom-Bridging-Header.h b/whilom/whilom-Bridging-Header.h deleted file mode 100644 index 1b2cb5d..0000000 --- a/whilom/whilom-Bridging-Header.h +++ /dev/null @@ -1,4 +0,0 @@ -// -// Use this file to import your target's public headers that you would like to expose to Swift. -// -