Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom protocol in 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!

like image 404
chakrit Avatar asked Jan 04 '09 19:01

chakrit


People also ask

What is custom protocol?

A custom protocol can be assigned the same name as a pre-defined protocol, in order to extend the number of IP addresses or ports associated with the original protocol. See Adding to a pre-defined protocol for more information.

What is a protocol handler windows?

Protocol handlers give the Windows Search indexer access to data stores, enabling the indexer to crawl the nodes of a data store and extract relevant information to index. Windows Search, for example, ships with protocol handlers for file system stores and for some versions of both Microsoft Outlook data stores.

What are protocol handlers?

A protocol handler is an application that knows how to handle particular types of links: for example, a mail client is a protocol handler for "mailto:" links.


3 Answers

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)

like image 166
James Cape Avatar answered Oct 26 '22 23:10

James Cape


The manual way to doing it for firefox:

open firefox
type in about:config to location bar
add new string
name:  network.protocol-handler.app.myapp
value: /path/to/program
like image 33
Cheery Avatar answered Oct 26 '22 22:10

Cheery


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.

like image 41
Charlie Martin Avatar answered Oct 26 '22 23:10

Charlie Martin