Custom protocol handlers Linux, Centos 7 for chrome
Asked Answered
W

1

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.

Whitmer answered 18/8, 2015 at 5:32 Comment(0)
B
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.

Brendin answered 10/2, 2016 at 15:3 Comment(2)
Thanks for this answer. It helped me solve my problem.Shena
Please note that ~/.local/share/applications/mimeapps.list is deprecated, please use ~/.config/mimeapps.list instead, or better yet, run xdg-mime default <desktopfile> <mimetype> (replace as needed) instead.Wenda

© 2022 - 2024 — McMap. All rights reserved.