Byron / open-rs

Open a path or URL with the system-defined program
http://byron.github.io/open-rs
MIT License
319 stars 49 forks source link

pass mime type to open #83

Closed dvc94ch closed 1 year ago

dvc94ch commented 1 year ago

I'm trying to open url's that don't contain a file extension, so they end up all being opened in the browser. It would be nice if the mime type could be supplied instead of relying on the file extension.

Byron commented 1 year ago

The way the library works, i.e. delegate the open-operation to an 'opener' program, makes it hard to impossible to consistently specify a mime type. Having checked open on MacOS, there is no flag for this and it's unclear how it could be passed to a browser, or other programs that it might select.

Given the difficulty that according to my current understanding borders at 'impossible', I am closing the issue.

However, if you have more information to share that might help implementing it or have a way to contribute such a feature, please feel welcome to do so - this issue can be reopened and PRs can be submitted. Thanks for your understanding.

dvc94ch commented 1 year ago

Well you support specifying the application to open it with. How about an api that returns the default application for a mime type? On Linux xdg-mime query default mimetype works

Byron commented 1 year ago

I think once similar programs have been determined for all platforms that this crate supports, it would be possible to implement that.

dvc94ch commented 1 year ago

mmh, looks like I can't do what I wanted anyway. at least on linux x-scheme-handler/http is used regardles of the url extension. so sadly I don't think there is a way to specify open x-scheme-handler/http && video/webm in mpv.

EDIT: wrote my own tool called xdg-url-open