Open external application with a url scheme in Firefox snap version

Hello,

I need to open an external application with an url scheme in Firefox snap version. It works on Kubuntu 23.10 but not Ubuntu 23.10. Both are the same Firefox snap version and the same snapd version (2.61.3+23.10). I want to know how to make it work with Ubuntu. Thank you in advance,

Hi ! @wylink .

You can use xdg-mime .

Please, show the output of this command :

gio mime x-scheme-handler/https

1 Like

Thank you for your help.

I do use xdg-mime to register the url scheme.

Here is the output on Ubuntu

 $ gio mime x-scheme-handler/https
Default application for “x-scheme-handler/https”: firefox_firefox.desktop
Registered applications:
	firefox.desktop
	google-chrome.desktop
	firefox_firefox.desktop
Recommended applications:
	firefox.desktop
	google-chrome.desktop
	firefox_firefox.desktop

However, if I check the url scheme in question, I get a different output:

$ gio mime x-scheme-handler/leaptofrogans
Default application for “x-scheme-handler/leaptofrogans”: frogansplayer.desktop
No registered applications
No recommended applications

Okay ! Well .

@wy.link , Show the output of this command :

xdg-mime query default x-scheme-handler/https

Hello baldeuniversel

Here is the output on Ubuntu:

$ xdg-mime query default x-scheme-handler/https
firefox_firefox.desktop

Well ! @wylink .

You can now choose your preferred browser using a pattern like this :

xdg-mime default firefox.desktop x-scheme-handler/https
(to choose firefox for the mime in question)

xdg-mime default firefox.desktop x-scheme-handler/http
(to choose firefox too for the mime in question …/http instead of …/https)

Thank you baldeuniversel.

This is however not exactly my problem. I want in fact to open an external application in Firefox by clicking on a link which itself is an url scheme, some thing like we click on a link zoomus://, whatsapp:// etc, it will open directly the corresponding installed application.

@wylink, can show an image to illustrate what you’re talking about ?

When I click the url scheme link, I get an error message:

But if we use xdg-open command, the related application can be opened correctly.

xdg-open leaptofrogans:frogans*demo-Tennis-Live

For your information,

  • I can open the application in Firefox if this is a firefox installed directly from deb package of Mozilla.
  • It works with Firefox snap version if we are in Kubuntu.

I found a bug description in snapd project. This is exactly my problem on Ubuntu. But I don’t think my problem comes from this bug since snap uses now xdg-desktop-portal, a more general solution.

Thank you in advance,

Okay @wylink , show the output of this command :

file    --mime-type    leaptofrogans:frogans*demo-Tennis-Live

Hello @baldeuniversel

Thank you for your reply, I got an output as below:

$ file --mime-type leaptofrogans:frogans*demo-Tennis-Live
leaptofrogans:frogans*demo-Tennis-Live: cannot open `leaptofrogans:frogans*demo-Tennis-Live' (No such file or directory)

FYI, that might be normal, e.g. if we use the command file to test https://www.google.com, we get the same result:

$ file --mime-type https://www.google.com/
https://www.google.com/: cannot open `https://www.google.com/' (No such file or directory)

Hi ! @wylink .

In this command you must give the absolute or relative path (where the leaptofrogans:frogans*demo-Tennis-Live is).

file --mime-type leaptofrogans:frogans*demo-Tennis-Live

Hello @baldeuniversel,

Thank you for your rapid reply.

leaptofrogans:frogans*demo-Tennis-Live is not a file, where leaptofrogans is the scheme just like http, https etc(ref: https://www.rfc-editor.org/rfc/rfc8589.html) while frogans * demo-Tennis-Live is the address of Frogans (ref: https://www.frogans.org/en/resources/ifap/access.html).

Okay @wylink, I’m a little confused . :slightly_smiling_face:

Let’s try this :

xdg-mime default firefox.desktop text/html

Or

xdg-mime default firefox_firefox.desktop text/html

Alright, @baldeuniversel

For my problem, I have tried the following command:

xdg-mime default frogansplayer.desktop x-scheme-handler/leaptofrogans

And it adds a line the .config/mimeapps.list under the [Default Applications] section:

[Default Applications]
x-scheme-handler/leaptofrogans=frogansplayer.desktop

That is why we can open the associated application (frogansplayer.desktop) with the xdg-open command in a terminal.

Well ! @wylink .

Can I see the content of this file frogansplayer.desktop ?

Inside ( frogansplayer.desktop ), normally, we must have something like this (below), otherwise we must define this:

[Desktop Entry]

MimeType=x-scheme-handler/leaptofrogans;

Hello @baldeuniversel

Sure, this is the content of the .local/share/applications/frogansplayer.desktop:

[Desktop Entry]
Name=Frogans Player
Exec=(absolute path)/frogansplayer %u
Icon=(absolute path)/frogans.xpm
Terminal=false
Type=Application
Categories=Network;WebBrowser;
MimeType=x-scheme-handler/leaptofrogans;

Okay @wylink, is there another frogansplayer.desktop ?

sudo find / -name frogansplayer.desktop -type f 2> /dev/null

To be sure, we agree that (absolute path) is grammatically incorrect :slight_smile: ?