mirror of
https://github.com/MonitorControl/MonitorControl.git
synced 2026-05-15 14:15:55 -06:00
* Update to Swift 5.0 and run `swiftformat`. * Refactor `MediaKeyTap` start/restart. * Remove useless comments. * Reorder files. * Add German translation. * Switch to Carthage. * Use `DDC.swift`. * Add `NSScreen` extension. * Simplify menu layout. * Hide the display’s built-in OSD. * Fix launch at login helper. * Fix `quitClicked` connection. * Refactor build phases. * Use `os_log` instead of `print`. * Use more specific check for `minReplyDelay`. * Add whitelist.
26 lines
801 B
Swift
26 lines
801 B
Swift
import Cocoa
|
|
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
func applicationDidFinishLaunching(_: Notification) {
|
|
let mainBundleID = Bundle.main.bundleIdentifier!.replacingOccurrences(of: "Helper", with: "")
|
|
|
|
let bundlePath = Bundle.main.bundlePath as NSString
|
|
|
|
guard NSRunningApplication.runningApplications(withBundleIdentifier: mainBundleID).isEmpty else {
|
|
return NSApp.terminate(self)
|
|
}
|
|
|
|
var pathComponents = bundlePath.pathComponents
|
|
let path = NSString.path(withComponents: Array(pathComponents[0..<(pathComponents.count - 4)]))
|
|
|
|
NSWorkspace.shared.launchApplication(path)
|
|
NSApp.terminate(nil)
|
|
}
|
|
|
|
func applicationWillTerminate(_: Notification) {}
|
|
}
|
|
|
|
let app = NSApplication.shared
|
|
let delegate = AppDelegate()
|
|
app.delegate = delegate
|
|
app.run()
|