9

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.

Sony Mathew
  • 2,929
  • 2
  • 22
  • 29
Fahad Rauf
  • 705
  • 2
  • 8
  • 17

1 Answers1

18

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.

Paweł K
  • 211
  • 1
  • 4
  • 7
  • 2
    Thanks for this answer. It helped me solve my problem. – thattolleyguy Apr 24 '18 at 22:01
  • Please note that `~/.local/share/applications/mimeapps.list` is deprecated, please use `~/.config/mimeapps.list` instead, or better yet, run `xdg-mime default ` (replace as needed) instead. – ack Oct 25 '21 at 17:32