mirror of
https://github.com/aculix/knotchy.git
synced 2026-10-27 07:15:53 +00:00
Initial release
This commit is contained in:
commit
4b67728cce
108 files changed
+13310
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import AppKit
|
||||
|
||||
enum ChromeExtension {
|
||||
/// Set once the Chrome Web Store assigns the item ID; until then the setup window hides the row.
|
||||
static let storeURL: URL? = nil
|
||||
|
||||
struct Browser: Equatable {
|
||||
let name: String
|
||||
let app: URL
|
||||
}
|
||||
|
||||
// Chromium browsers all install from the Chrome Web Store.
|
||||
private static let candidates = [("Chrome", "com.google.Chrome"), ("Edge", "com.microsoft.edgemac"),
|
||||
("Brave", "com.brave.Browser"), ("Arc", "company.thebrowser.Browser")]
|
||||
|
||||
static func installedBrowser() -> Browser? {
|
||||
guard storeURL != nil else { return nil }
|
||||
for (name, id) in candidates {
|
||||
if let app = NSWorkspace.shared.urlForApplication(withBundleIdentifier: id) { return Browser(name: name, app: app) }
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
static func open(in browser: Browser) {
|
||||
guard let storeURL else { return }
|
||||
NSWorkspace.shared.open([storeURL], withApplicationAt: browser.app, configuration: NSWorkspace.OpenConfiguration())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user