Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't open files and links anymore #49

Open
sedrubal opened this issue Jun 17, 2021 · 19 comments
Open

Can't open files and links anymore #49

sedrubal opened this issue Jun 17, 2021 · 19 comments

Comments

@sedrubal
Copy link

I'm not able to open links and files from inside flatpak contexts anymore. I have several apps that are able to open links (in my case Obsidian) or files (Zotero). I assume they use something like xdg-open. But nothing happens. When I click on links in Obsidian, I can see this when I use flatpak run ... but nothing else happens:

Opening URL: <desired URL is here>

In Zotero I could open files before and a system dialogue was shown where I could choose an application. But nothing happens now.

Using xdg-open <URL or file> works as expected outside flatpak of course.
I'm using Flatpak 1.11.1 on Archlinux.

I'm very sorry to post such a vague issue and I'm sorry if this is off-topic, but I don't know, where I can find help instead.

@sedrubal
Copy link
Author

I'm not sure what the problem was and what fixed the problem but after a reboot it works again. Seems like something in my environment was broken.

@sedrubal sedrubal reopened this Jun 23, 2021
@sedrubal
Copy link
Author

I just found out that this problem is present when I'm running wayland. It was solved, because I switched to X11. I'm using plasma desktop

@RossComputerGuy
Copy link

Any solutions for Sway on nixOS with every app in a Flatpak? I can't seem to open any links without copying and pasting into Firefox. I got the XDG portals for WLR and GTK.

@TingPing
Copy link
Member

This bug is probably to be reported to flatpak/xdg-desktop-portal.

All xdg-open does here is a dbus call to org.freedesktop.portal.Desktop.

You can test this theory with a command like gdbus call -e -d org.freedesktop.portal.Desktop -o /org/freedesktop/portal/desktop -m org.freedesktop.portal.OpenURI.OpenURI '' 'https://example.org' {}

@RossComputerGuy
Copy link

That doesn't work, I get an error saying there's no app installed.

@TingPing
Copy link
Member

What does gio mime x-scheme-handler/https say (on the host)?

@RossComputerGuy
Copy link

Default application for “x-scheme-handler/https”: org.mozilla.firefox.desktop
Registered applications:
	org.mozilla.firefox.desktop
Recommended applications:
	org.mozilla.firefox.desktop

@TingPing
Copy link
Member

I believe whatever is managing your session doesn't properly have XDG_DATA_DIRS configured. It needs to include /var/lib/flatpak/exports/share and $HOME/.local/share/flatpak/exports/share.

So xdg-desktop-portal is getting activated into an environment without these set and it fails to find your browser.

@RossComputerGuy
Copy link

Could it be how nixOS sets up stuff? I ran printenv XDG_DATA_DIRS and it shows this.

/nix/store/bv315gbg9m93ralhk6yiabc96n1a5c7i-sway-1.7/share:/nix/store/m0d6hi92gpw5g13z02cwdcp7r661cq7i-desktops/share:/home/ross/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/home/ross/.nix-profile/share:/etc/profiles/per-user/ross/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share

@TingPing
Copy link
Member

I'm not really familiar with it. The nixOS community may be helpful.

@RossComputerGuy
Copy link

I found out that /home/ross/.local/share/flatpak/exports/share does not exist for some reason.

@TingPing
Copy link
Member

If you've never used flatpak install --user its probably not going to exist.

@RossComputerGuy
Copy link

I never knew there was that option. I just copy the install command from Flathub.

@RossComputerGuy
Copy link

Alright, I fixed it. I had to add in the /var/lib/flatpak/exports/share path.

@RossComputerGuy
Copy link

I've done some more digging into this issue and have determined that the XDG Desktop Portal isn't quite working as expected. I can't get it working to open links in Flatpaks when the portal is ran through the systemd user service. However, it works when I run it manually. Despite XDG_DATA_DIRS being set to /nix/store/w5cq1n267dz0alzzmw60zv2pxarid67x-xdg-desktop-portal-1.14.4/share:/nix/store/wbsmj0d84l1r0qwr2cl2myzymqrw1hfk-gtk+3-3.24.34/share/gsettings-schemas/gtk+3-3.24.34:/nix/store/6vk1bk1pgvfl1jsm33p3ggzsln589v0m-gsettings-desktop-schemas-42.0/share/gsettings-schemas/gsettings-desktop-schemas-42.0:/var/lib/flatpak/exports/share:/nix/store/m0d6hi92gpw5g13z02cwdcp7r661cq7i-desktops/share:/home/ross/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/home/ross/.nix-profile/share:/etc/profiles/per-user/ross/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share for the xdg-desktop-portal. xdg-open works when I trigger outside of Flatpaks but it fails from inside Flatpaks.

/var/lib/flatpak/exports/share/applications/mimeinfo.cache contains the correct entries for Firefox:

application/vnd.mozilla.xul+xml=org.mozilla.firefox.desktop;
application/xhtml+xml=org.mozilla.firefox.desktop;
text/html=org.mozilla.firefox.desktop;
text/mml=org.mozilla.firefox.desktop;
text/xml=org.mozilla.firefox.desktop;
x-scheme-handler/http=org.mozilla.firefox.desktop;
x-scheme-handler/https=org.mozilla.firefox.desktop;

I tested with Discord as I know that uses links and found out some XDG_DATA_DIRS doesn't exist. Specifically these two /run/host/user-share and /run/host/share.

@TingPing
Copy link
Member

TingPing commented Oct 2, 2022

I'm not super familiar with how the systemd environment gets set but flatpak installs a handful of files such as /usr/lib/systemd/system-environment-generators/60-flatpak-system-only and one of them must be expected to be picked up by systemd. I'm not sure how or if that gets to the xdg-desktop-portal service, maybe there is supposed to be some dependency there.

@RossComputerGuy
Copy link

@TingPing Yeah, nixOS doesn't have system-environment-generators but it has user-environment-generators. It doesn't have anything for Flatpak with systemd as far as I can tell.

@Nycta-b424b3c7
Copy link

Is there a way to force Obsidian and flatpak to be more verbose? I really want to troubleshoot it but it just doesn't provide enough information. I'm on Void Linux and this doesn't work for me either.

@forest-cat
Copy link

Alright, I fixed it. I had to add in the /var/lib/flatpak/exports/share path.

Where did you add that path exactly? And how?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants