-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macOS: Use system API to open links #5256
Comments
Given this is a native app we could actually use SwiftUI's Specifically I'm referring to: |
I was interested in taking a crack at this feature but was looking for some more clarity on the required changes. Would the approach here involve invoking the const NSWorkspace = objc.getClass("NSWorkspace");
const shared = NSWorkspace.msgSend(objc.Object, objc.sel("shared"));
_ = shared.msgSend(bool, objc.sel("open:"), .{ url }); |
@matthebrown personally my preference would be the safer high-level APIs provided by SwiftUI. Was there any reason specifically you wanted implement it using older Obj-C |
That makes sense, I'm just a little unsure what to do with this existing logic in |
Perhaps we need to convert opening URLs into an apprt action. That way it would be easier for each apprt to implement native experiences, plus make it easier for macOS to use native Swift code to implement the action. |
I think converting this to an apprt action makes sense. The |
FWIW I agree, I like the idea that it allows each platform to handle things more appropriately as well 👍 |
Discussed in #5200
Originally posted by sindresorhus January 18, 2025
Currently, it uses the
open
command. The problem with using that is that it makes it impossible for browser pickers apps to detect that the link is opened from Ghostty, because by the time the app checks for the source app, theopen
command has exited. It should also be slightly faster to use the system API: https://developer.apple.com/documentation/appkit/nsworkspace/open(_:)?language=objcI'm referring to: https://github.com/ghostty-org/ghostty/blob/72d085525b22d66468c5969a4d507a0fa68d4a04/src/os/open.zig#L32C9-L41C11
Specifically, Velja uses the source app to let users create advanced rules for which browser to use depending on the source app.
The text was updated successfully, but these errors were encountered: