pop-os / xdg-desktop-portal-cosmic

GNU General Public License v3.0
43 stars 37 forks source link

Background portal #70

Open joshuamegnauth54 opened 3 months ago

joshuamegnauth54 commented 3 months ago

Requires the access portal to be enabled or else it does nothing

I based my implementation on the official specs as well as code from GNOME, KDE, Xapp (Xfce), and Pantheon (elementary). KDE's immaculately readable codebase served as this implementation's primary inspiration.

Like KDE, I intend to show a dialog, so the user may choose whether to grant privileges to an application. I will also provide an option to bypass the dialog for greater choice especially considering that GNOME automatically grants permissions.

According to the docs, the Autostart method is deprecated. However, I think I still need to implement it because background requests aren't routed to the COSMIC portal unless it's available. Autostart is implemented

Closes: #49

ids1024 commented 2 months ago

According to the docs, the Autostart method is deprecated. However, I think I still need to implement it because background requests aren't routed to the COSMIC portal unless it's available.

Looks like it was deprecated in May (https://github.com/flatpak/xdg-desktop-portal/commit/458560c768d5acf7e163ba57f219725294f5ff51) and the last release was in April. So presumably it's still required on released versions of xdg-desktop-portal, but won't in the next.

joshuamegnauth54 commented 2 months ago

Their reasoning makes sense. Every portal backend I checked implements autostart the same way (which, in a way, was really nice because it made it easier to implement here :joy: ).

This is finally done and it works too! I learned a lot in the process as well.

gabriele2000 commented 2 weeks ago

Can't wait until this is approved!

Would this also fix cosmic-files not being able to supply files for flatpak uploads? For example: uploading a file using cosmic-file as picker in firefox (flatpak)

joshuamegnauth54 commented 2 weeks ago

Nope! But I can try to look into that after finishing some other patches I'm working on. :smiley_cat:

The background portal allows sandboxed apps permission to run in the background without any windows open.

gabriele2000 commented 2 weeks ago

Nope! But I can try to look into that after finishing some other patches I'm working on. 😺

The background portal allows sandboxed apps permission to run in the background without any windows open.

I'll try to provide logs to help with the implementation

joshuamegnauth54 commented 2 weeks ago

Sounds good. I'll take a look into it soon. I can't guarantee I'll be able to fix it though. :laughing:

gabriele2000 commented 2 weeks ago

Sounds good. I'll take a look into it soon. I can't guarantee I'll be able to fix it though. 😆

Here's the spam, it could be useful

``` nov 07 14:07:28 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activating service name='org.freedesktop.systemd1' requested by ':1.126' (uid=1000 pid=2154 comm="cosmic-launcher") nov 07 14:07:28 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 nov 07 14:07:28 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activating service name='org.freedesktop.Flatpak' requested by ':1.128' (uid=1000 pid=4045 comm="/usr/bin/flatpak run --branch=stable --arch=x86_64") nov 07 14:07:28 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Successfully activated service 'org.freedesktop.Flatpak' nov 07 14:07:28 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activating service name='org.freedesktop.portal.Documents' requested by ':1.128' (uid=1000 pid=4045 comm="/usr/bin/flatpak run --branch=stable --arch=x86_64") nov 07 14:07:28 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Successfully activated service 'org.freedesktop.portal.Documents' nov 07 14:07:28 msi-gp72m org.freedesktop.portal.Documents[4087]: fusermount3: failed to access mountpoint /run/user/1000/doc: Permission denied nov 07 14:07:28 msi-gp72m org.freedesktop.portal.Documents[4080]: error: fuse init failed: Can't mount path /run/user/1000/doc nov 07 14:07:28 msi-gp72m systemd[1996]: Started app-flatpak-com.github.wwmm.easyeffects-4045.scope. nov 07 14:07:28 msi-gp72m rtkit-daemon[1726]: Successfully made thread 4104 of process 4096 owned by '1000' RT at priority 20. nov 07 14:07:28 msi-gp72m rtkit-daemon[1726]: Supervising 7 threads of 4 processes of 1 users. nov 07 14:07:28 msi-gp72m pipewire[2010]: mod.client-node: detected old client version 4 nov 07 14:07:28 msi-gp72m pipewire[2010]: mod.client-node: detected old client version 4 nov 07 14:07:28 msi-gp72m pipewire[2010]: mod.client-node: detected old client version 4 nov 07 14:07:28 msi-gp72m pipewire[2010]: mod.client-node: detected old client version 4 nov 07 14:07:29 msi-gp72m pipewire[2010]: mod.client-node: detected old client version 4 nov 07 14:07:29 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activating service name='org.freedesktop.portal.IBus' requested by ':1.134' (uid=1000 pid=4092 comm="xdg-dbus-proxy --args=53") nov 07 14:07:29 msi-gp72m org.freedesktop.portal.IBus[4116]: Not connected to the ibus bus nov 07 14:07:29 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activated service 'org.freedesktop.portal.IBus' failed: Process org.freedesktop.portal.IBus exited with status 1 nov 07 14:07:35 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activating service name='org.freedesktop.systemd1' requested by ':1.135' (uid=1000 pid=2372 comm="cosmic-app-list") nov 07 14:07:35 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1 nov 07 14:07:36 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activating service name='org.freedesktop.portal.Documents' requested by ':1.137' (uid=1000 pid=4122 comm="/usr/bin/flatpak run --branch=beta --arch=x86_64 -") nov 07 14:07:36 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Successfully activated service 'org.freedesktop.portal.Documents' nov 07 14:07:36 msi-gp72m org.freedesktop.portal.Documents[4144]: fusermount3: failed to access mountpoint /run/user/1000/doc: Permission denied nov 07 14:07:36 msi-gp72m org.freedesktop.portal.Documents[4137]: error: fuse init failed: Can't mount path /run/user/1000/doc nov 07 14:07:36 msi-gp72m systemd[1996]: Started app-flatpak-org.mozilla.firefox-4122.scope. nov 07 14:07:37 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activating service name='org.freedesktop.portal.IBus' requested by ':1.141' (uid=1000 pid=4149 comm="xdg-dbus-proxy --args=46") nov 07 14:07:37 msi-gp72m org.freedesktop.portal.IBus[4225]: Not connected to the ibus bus nov 07 14:07:37 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activated service 'org.freedesktop.portal.IBus' failed: Process org.freedesktop.portal.IBus exited with status 1 nov 07 14:08:00 msi-gp72m chronyd[1243]: Selected source 15.237.97.214 (paris.time.system76.com) nov 07 14:11:35 msi-gp72m geoclue[2857]: Failed to query location: Query location SOUP error: Not Found nov 07 14:11:50 msi-gp72m systemd[1996]: Starting launchpadlib-cache-clean.service - Clean up old files in the Launchpadlib cache... nov 07 14:11:50 msi-gp72m systemd[1996]: Finished launchpadlib-cache-clean.service - Clean up old files in the Launchpadlib cache. nov 07 14:12:17 msi-gp72m PackageKit[3316]: daemon quit nov 07 14:12:17 msi-gp72m systemd[1]: packagekit.service: Deactivated successfully. nov 07 14:15:01 msi-gp72m CRON[5212]: pam_unix(cron:session): session opened for user root(uid=0) by root(uid=0) nov 07 14:15:01 msi-gp72m CRON[5213]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1) nov 07 14:15:01 msi-gp72m CRON[5212]: pam_unix(cron:session): session closed for user root nov 07 14:16:41 msi-gp72m geoclue[2857]: Failed to query location: Query location SOUP error: Not Found nov 07 14:16:43 msi-gp72m geoclue[2857]: Failed to query location: Query location SOUP error: Not Found nov 07 14:17:01 msi-gp72m CRON[5259]: pam_unix(cron:session): session opened for user root(uid=0) by root(uid=0) nov 07 14:17:01 msi-gp72m CRON[5260]: (root) CMD (cd / && run-parts --report /etc/cron.hourly) nov 07 14:17:01 msi-gp72m CRON[5259]: pam_unix(cron:session): session closed for user root nov 07 14:19:20 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activating service name='org.freedesktop.portal.Documents' requested by ':1.34' (uid=1000 pid=2709 comm="/usr/libexec/xdg-desktop-portal") nov 07 14:19:20 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Successfully activated service 'org.freedesktop.portal.Documents' nov 07 14:19:20 msi-gp72m org.freedesktop.portal.Documents[5445]: fusermount3: failed to access mountpoint /run/user/1000/doc: Permission denied nov 07 14:19:20 msi-gp72m org.freedesktop.portal.Documents[5438]: error: fuse init failed: Can't mount path /run/user/1000/doc nov 07 14:19:22 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activating service name='org.freedesktop.portal.Documents' requested by ':1.34' (uid=1000 pid=2709 comm="/usr/libexec/xdg-desktop-portal") nov 07 14:19:22 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Successfully activated service 'org.freedesktop.portal.Documents' nov 07 14:19:22 msi-gp72m org.freedesktop.portal.Documents[5477]: fusermount3: failed to access mountpoint /run/user/1000/doc: Permission denied nov 07 14:19:22 msi-gp72m org.freedesktop.portal.Documents[5468]: error: fuse init failed: Can't mount path /run/user/1000/doc nov 07 14:19:22 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Activating service name='org.freedesktop.portal.Documents' requested by ':1.34' (uid=1000 pid=2709 comm="/usr/libexec/xdg-desktop-portal") nov 07 14:19:22 msi-gp72m dbus-daemon[2061]: [session uid=1000 pid=2059] Successfully activated service 'org.freedesktop.portal.Documents' nov 07 14:19:22 msi-gp72m org.freedesktop.portal.Documents[5489]: fusermount3: failed to access mountpoint /run/user/1000/doc: Permission denied nov 07 14:19:22 msi-gp72m org.freedesktop.portal.Documents[5479]: error: fuse init failed: Can't mount path /run/user/1000/doc nov 07 14:19:22 msi-gp72m xdg-desktop-por[2709]: Failed to register file:///home/gabriele/Videos/Registrazioni/2024-11-06%2023-45-58.mkv: GDBus.Error:org.freedesktop.DBus.Error.NoReply: Message recipient disconnected from message bus without replying ```

There's also this weird thing:

gabriele@msi-gp72m:~$ sudo journalctl -e | grep xdg-desktop-portal-cosmic
[sudo] password for gabriele:
nov 07 14:06:16 msi-gp72m cosmic-session[2062]: starting process ' WAYLAND_DISPLAY=wayland-1 DISPLAY=:0 XDG_SESSION_TYPE=wayland WAYLAND_SOCKET=77 PORTAL_WAYLAND_SOCKET=59 /usr/libexec/xdg-desktop-portal-cosmic '
nov 07 14:06:16 msi-gp72m cosmic-session[2062]: Failed to spawn scope for /usr/libexec/xdg-desktop-portal-cosmic. Creating transient unit failed with org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
joshuamegnauth54 commented 1 week ago

@gabriele2000 I'm not sure what's causing the permission errors. :thinking: The rest of the portal works, right? Like screenshots?

You should open an issue with the same log in case someone else knows, but I'll continue looking into it as well.

gabriele2000 commented 1 week ago

@gabriele2000 I'm not sure what's causing the permission errors. 🤔 The rest of the portal works, right? Like screenshots?

You should open an issue with the same log in case someone else knows, but I'll continue looking into it as well.

I hope the upgrade from 22.04 to 24.04 didn't mess something up too bad, because now the cursor in some flatpak apps is gigantic and there's this weird error. Anyway, one way to reproduce it is to use firefox (flatpak version) and try to upload a random file using cosmic-files (the picker is cosmic-files now)