Custom protocol handlers Linux, Centos 7 for chrome

5.9k Views Asked by At

I have developed an application which is invoked on a button click on my website. I was using NPAPI for this task. However recently google has deprecated NPAPI so I called my application using custom protocol handler like "myapp://"

On windows my application and handlers are working perfectly fine.

Now I want to do the same in Linux. I need to do this for CentOS preferably 7 and for Chrome web browser.

I did some research but most of the help on web is for firefox but I specifically need it for chrome. My desktop is GNOME based, kindly help please.

1

There are 1 best solutions below

2
On

To add protocol handler myapp:// you need to add file myapp.desktop to ~/.local/share/applications. It looks like this:

[Desktop Entry]
Name=myapp
Exec=/path/to/your/program %u
Type=Application
Terminal=false
MimeType=x-scheme-handler/myapp;

Exec and MimeType are very important.

Then you need to add line

x-scheme-handler/myapp=myapp.desktop

to file ~/.local/share/applications/mimeapps.list under [Default Applications]

At the end you will probably need to type command:

update-desktop-database ~/.local/share/applications

For me it was working on all browsers.