karaggeorge / kap-hide-clock

MIT License
17 stars 1 forks source link

Quit Dato before recording and relaunch it after #3

Open sindresorhus opened 4 years ago

sindresorhus commented 4 years ago

Per Slack discussion. This will make it easier for other apps to integrate too as they'll only need to get their bundle ID added here.

Electron is not able to quit and launch other apps, so I think you'll have to make another binary package.

You can use this to launch an app:

func launchApp(_ url: URL) {
    if #available(macOS 10.15, *) {
        let configuration = NSWorkspace.OpenConfiguration()
        NSWorkspace.shared.openApplication(at: url, configuration: configuration) { _, _error_ in } // TODO: Handle the error.
    } else {
        _ = try? NSWorkspace.shared.launchApplication(at: url, configuration: [:])
    }
}

And this to quit an app:

NSRunningApplication.runningApplications(withBundleIdentifier: "...").first?.terminate()

And to get the URL for an app: https://github.com/sindresorhus/app-path