Skip to content

Commit 896c8dc

Browse files
committed
add uninstall menu item, add intel binary build, code cleanup
1 parent 0741c96 commit 896c8dc

5 files changed

Lines changed: 25 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ jobs:
5454
-scheme Awayke \
5555
-configuration Release \
5656
-derivedDataPath build \
57+
ARCHS="arm64 x86_64" \
58+
ONLY_ACTIVE_ARCH=NO \
5759
CODE_SIGN_STYLE=Manual \
5860
CODE_SIGN_IDENTITY="Developer ID Application" \
5961
DEVELOPMENT_TEAM="$TEAM_ID" \

Awayke/AppDelegate.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
9898
menu.addItem(helperRow)
9999
}
100100

101+
menu.addItem(.separator())
102+
menu.addItem(NSMenuItem(title: "Uninstall Awayke…", action: #selector(menuUninstall), keyEquivalent: ""))
101103
menu.addItem(.separator())
102104
menu.addItem(NSMenuItem(title: "Quit Awayke", action: #selector(menuQuit), keyEquivalent: "q"))
103105

@@ -123,17 +125,26 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
123125
let item = NSMenuItem(title: "Helper not found (using fallback)", action: nil, keyEquivalent: "")
124126
item.isEnabled = false
125127
return item
126-
case .registrationFailed(let detail):
127-
let item = NSMenuItem(title: "Helper failed: \(detail)", action: nil, keyEquivalent: "")
128-
item.isEnabled = false
129-
return item
130128
}
131129
}
132130

133131
@objc private func menuToggle() { toggle() }
134132
@objc private func menuApproveHelper() { helper.revealInSystemSettings() }
135133
@objc private func menuQuit() { NSApp.terminate(nil) }
136134

135+
@objc private func menuUninstall() {
136+
let alert = NSAlert()
137+
alert.messageText = "Uninstall Awayke?"
138+
alert.informativeText = "This will remove Awayke's background helper from System Settings and quit the app. You can then move Awayke.app to the Trash."
139+
alert.alertStyle = .warning
140+
alert.addButton(withTitle: "Uninstall")
141+
alert.addButton(withTitle: "Cancel")
142+
guard alert.runModal() == .alertFirstButtonReturn else { return }
143+
144+
helper.unregister()
145+
NSApp.terminate(nil)
146+
}
147+
137148
private func refreshStatusItem() {
138149
guard let button = statusItem?.button else { return }
139150
guard let base = NSImage(named: "StatusIcon") else { return }

Awayke/DisplayWakeKeeper.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ final class DisplayWakeKeeper {
1313

1414
private var assertionID: IOPMAssertionID = 0
1515

16-
var isHolding: Bool { assertionID != 0 }
17-
1816
func prevent() {
1917
guard assertionID == 0 else { return }
2018
let result = IOPMAssertionCreateWithName(

Awayke/HelperManager.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ enum HelperState: Equatable {
1212
case awaitingApproval
1313
case enabled
1414
case notFound
15-
case registrationFailed(String)
1615
}
1716

1817
enum HelperError: LocalizedError {
@@ -72,6 +71,14 @@ final class HelperManager {
7271
SMAppService.openSystemSettingsLoginItems()
7372
}
7473

74+
func unregister() {
75+
do {
76+
try service.unregister()
77+
} catch {
78+
NSLog("Awayke: SMAppService.unregister() failed: \((error as NSError).localizedDescription)")
79+
}
80+
}
81+
7582
func setSleepDisabled(_ disable: Bool) async throws {
7683
let proxy = try ensureProxy()
7784
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in

AwaykeHelper/AwaykeHelperProtocol.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import Foundation
66

77
@objc public protocol AwaykeHelperProtocol {
8-
/// `disable` → true runs `pmset -a disablesleep 1`; false runs `… 0`.
9-
/// Reply is nil on success, NSError on failure.
108
func setSleepDisabled(_ disable: Bool, reply: @escaping (NSError?) -> Void)
119
}
1210

0 commit comments

Comments
 (0)