Skip to content

Commit

Permalink
cleanup proj
Browse files Browse the repository at this point in the history
  • Loading branch information
insanj committed Mar 12, 2021
1 parent 5a2dbac commit 784f6ba
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 58 deletions.
16 changes: 6 additions & 10 deletions whilom.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@
1E2FA93525FB12FE00D7D123 /* whilom.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = whilom.entitlements; sourceTree = "<group>"; };
1E396DB025FB138C008E2122 /* whilomDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = whilomDebug.entitlements; sourceTree = "<group>"; };
1E396DC425FB4C26008E2122 /* NSImage+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSImage+Extension.swift"; sourceTree = "<group>"; };
1E5B4CFE25FB74D700092422 /* whilom-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "whilom-Bridging-Header.h"; sourceTree = "<group>"; };
1E5B4D0725FB779900092422 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
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 = "<group>"; };
1EE4E20A24F97E240097C32C /* whilom.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = whilom.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -70,9 +66,6 @@
isa = PBXGroup;
children = (
1E5B4D6925FBFE4B00092422 /* Cocoa.framework */,
1E5B4D3B25FBFC5E00092422 /* Security.framework */,
1E5B4D3925FBFC5A00092422 /* Foundation.framework */,
1E5B4D1025FBFA4800092422 /* ServiceManagement.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
50 changes: 16 additions & 34 deletions whilom/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -350,6 +331,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {

enableSleepScript = buildEnableSleepScript(rememberedPassword)
disableSleepScript = buildDisableSleepScript(rememberedPassword)
rememberedPassword = nil
}
}

Expand Down
7 changes: 0 additions & 7 deletions whilom/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,5 @@
<true/>
<key>NSSupportsSuddenTermination</key>
<true/>
<key>NSSystemAdministrationUsageDescription</key>
<string>Enable or disable your Mac from sleeping.</string>
<key>SMPrivilegedExecutables</key>
<dict>
<key>com.insanj.whilom.HelperTool</key>
<string>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)</string>
</dict>
</dict>
</plist>
3 changes: 1 addition & 2 deletions whilom/NSImage+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
// 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
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")
Expand Down
3 changes: 2 additions & 1 deletion whilom/String+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions whilom/whilom-Bridging-Header.h

This file was deleted.

0 comments on commit 784f6ba

Please sign in to comment.