flatpak / flatpak-xdg-utils

Simple portal-based commandline tools for use inside flatpak sandboxes
GNU Lesser General Public License v2.1
34 stars 14 forks source link

Can't open files and links anymore #49

Open sedrubal opened 3 years ago

sedrubal commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

TingPing commented 2 years ago

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

RossComputerGuy commented 2 years ago
Default application for “x-scheme-handler/https”: org.mozilla.firefox.desktop
Registered applications:
    org.mozilla.firefox.desktop
Recommended applications:
    org.mozilla.firefox.desktop
TingPing commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

RossComputerGuy commented 2 years ago

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

TingPing commented 2 years ago

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

RossComputerGuy commented 2 years ago

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

RossComputerGuy commented 2 years ago

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

RossComputerGuy commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 months ago

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.