Linux 中的自定义协议?
我正在尝试将我的一个爱好项目移植到Linux。 最好是 Mono,因为它是用 C# 编写的。 但我也在研究Python。
该应用程序的功能之一是它需要与自定义协议关联,以便当用户单击应用程序网站上的如下链接时调用该应用程序:
myapp://module/action
在linux/unix系统中如何做到这一点? 我可以像 Windows 中那样关联系统范围的处理程序吗? 或者它是否需要依赖于浏览器?
在谷歌上找不到任何东西。 而且我对linux编程一窍不通。
我需要一些指点。 谢谢!
I am attempting to port one of my hobby project to linux. Preferrably to Mono since it is written in C#. But I am looking into Python as well.
One of the feature of the application is that it needs to associate with a custom protocol so the application is invoked when the user clicks links like this on the app's website:
myapp://module/action
A custom protocol like this, this and this.
How can that be done in linux/unix systems? Can I associate a system-wide handler like in Windows? or does it need to be browser-dependent?
Can't find anything on Google. And I am utterly clueless at linux programming.
I need some pointers. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在理想情况下,此类事情由桌面环境(KDE、GNOME、XFCE)处理,并且 Firefox 尊重这些设置——至少在 Ubuntu、Fedora 和 OpenSUSE 上应该这样做。 YMMV:
将新的 URI 方案处理程序集成到 GNOME 和 Firefox
添加适用于 Firefox (KDE) 的协议处理程序
In the ideal situation, this sort of thing is handled by the desktop environment (KDE, GNOME, XFCE), and Firefox respects those settings---it should do so on Ubuntu, Fedora, and OpenSUSE, at least. YMMV:
Integrating a new URIs Scheme Handler to GNOME and Firefox
Adding a protocol handler for firefox (KDE)
Firefox 的手动操作方法:
The manual way to doing it for firefox:
不会有单一的答案,因为这最多会在 X 窗口管理器级别发生。 一般来说,您需要有一些代码块可以放入您的路径中,并将名称与协议相关联。 查看 about:config 页面,这是设置处理程序的地方。
这实际上也是 Windows 所做的一切,只是注册表中的内容而已。
对于 Firefox 来说,这看起来是一个不错的描述。
There's not going to be a single answer, because that will be happening at the X window manager level at best. In general, you're going to need to have some chunk of code you can put into your path, and associate the name with the protocol. Have a look at the about:config page, which is where the handlers are set up.
That's really all that Windows does too, it's just that stuff is in the registry.
This looks like a decent drescription for Firefox.
它必须依赖于浏览器。 Linux 中没有跨浏览器的方法来关联 URL 处理程序。
It has to be browser-dependent. There's no cross-browser way of associating URL handlers in Linux.