Skip to content

Commit

Permalink
Add sleep and run a non blocking xpc server with helper exiting after…
Browse files Browse the repository at this point in the history
… 5 seconds
  • Loading branch information
rurza committed Apr 27, 2023
1 parent 28ceb78 commit 2fe1cc6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
9 changes: 4 additions & 5 deletions App/BatFiApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}
SeparatorItem()
MenuItem("Turn off charging").onSelect { [weak self] in
guard let self = self else { return }
Task {
guard let self = self else { return }
try await self.charging.turnOffCharging()
}
}
MenuItem("Turn on charging").onSelect { [weak self] in
Task {
guard let self = self else { return }
try await self.charging.autoChargingMode()
}
}
MenuItem("Inhibit charging").onSelect { [weak self] in
guard let self = self else { return }

}
SeparatorItem()
MenuItem("Quit BatFi")
.onSelect(target: NSApp, action: #selector(NSApp.terminate(_:)))
Expand Down
2 changes: 2 additions & 0 deletions BatFi.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 5B3C14C929EB431600746A53 /* AppConfig.xcconfig */;
buildSettings = {
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
Expand Down Expand Up @@ -642,6 +643,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 5B3C14C929EB431600746A53 /* AppConfig.xcconfig */;
buildSettings = {
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
Expand Down
4 changes: 2 additions & 2 deletions Helper/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<plist version="1.0">
<dict>
<key>BuildHash</key>
<string>36ba4cc968d825d7202fc9b666920e9369c1ae45ee20e3094f97622e344efafe</string>
<string>600a2a59be0ed766969702751a25977e941c758720764c96f359af85f035a7c8</string>
<key>CFBundleIdentifier</key>
<string>software.micropixels.BatFi.Helper</string>
<key>CFBundleVersion</key>
<string>1.0.87</string>
<string>1.0.88</string>
<key>SMAuthorizedClients</key>
<array>
<string>anchor apple generic and identifier "software.micropixels.BatFi" and info[CFBundleVersion] &gt;= "1.0.0" and certificate leaf[subject.OU] = "YL78V8PY6H"</string>
Expand Down
4 changes: 3 additions & 1 deletion Helper/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ server.registerRoute(XPCRoute.charging, handler: RouteHandler.charging)
server.registerRoute(XPCRoute.smcStatus, handler: RouteHandler.smcStatus)
server.setErrorHandler(errorHandler)

server.startAndBlock()
server.start()
try await Task.sleep(for: .seconds(5))
exit(0)

0 comments on commit 2fe1cc6

Please sign in to comment.