MonitorControl/MonitorControlHelper/main.swift
Markus Reiter 6e91c71353 Various Enhancements (#66)
* 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.
2019-05-07 15:01:26 +02:00

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()