mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 11:43:24 +01:00
[AltServer] Updates LaunchAtLogin dependency
This commit is contained in:
26
Carthage/Checkouts/LaunchAtLogin/Sources/LaunchAtLoginHelper/main.swift
vendored
Normal file
26
Carthage/Checkouts/LaunchAtLogin/Sources/LaunchAtLoginHelper/main.swift
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import AppKit
|
||||
|
||||
// TODO: When targeting macOS 11, convert this to use `App` protocol and remove `NSPrincipalClass` in Info.plist.
|
||||
|
||||
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
let bundleIdentifier = Bundle.main.bundleIdentifier!
|
||||
let mainBundleIdentifier = bundleIdentifier.replacingOccurrences(of: #"-LaunchAtLoginHelper$"#, with: "", options: .regularExpression)
|
||||
|
||||
// Ensures the app is not already running.
|
||||
guard NSRunningApplication.runningApplications(withBundleIdentifier: mainBundleIdentifier).isEmpty else {
|
||||
NSApp.terminate(nil)
|
||||
return
|
||||
}
|
||||
|
||||
let pathComponents = (Bundle.main.bundlePath as NSString).pathComponents
|
||||
let mainPath = NSString.path(withComponents: Array(pathComponents[0...(pathComponents.count - 5)]))
|
||||
NSWorkspace.shared.launchApplication(mainPath)
|
||||
NSApp.terminate(nil)
|
||||
}
|
||||
}
|
||||
|
||||
private let app = NSApplication.shared
|
||||
private let delegate = AppDelegate()
|
||||
app.delegate = delegate
|
||||
app.run()
|
||||
Reference in New Issue
Block a user