Wayland screenshots in /tmp

Gnome under wayland saves a temporary version of a screenshot in /tmp.
Is it possible to access these files or redirect the save location to one inside the snap?

If you’re talking about the org.gnome.Shell.Screenshot D-Bus API, I wouldn’t have thought you’d be able to access it from a strict confined snap. So access to /tmp paths is kind of beside the point.

I would suggest using the xdg-desktop-portal org.freedesktop.portal.Screenshot API instead, which will make sure the screenshot is made available in a location you can access, and is safer for the user.

Do I have to add the plug for that api?
I’m using the kde-neon extension.
The yaml is here: https://github.com/ksnip/ksnip/blob/master/snap/snapcraft.yaml
If I leave it as is I get a dbus error.

If I add GTK_USE_PORTAL: 1 to the snap environment I get a bit further along.
The program is however not able to import the screenshot. Where should it be saved?

EDIT: they don’t appear to be in /tmp/snap.ksnip/tmp

You should only need to plug desktop, which the kde-neon Snapcraft extension should already handle for you.

Taking a quick look at that code, you’d probably need to add a new backend implementing the xdg-desktop-portal screenshot API, and work have the snap version of the app use that. You could start with the GnomeWaylandImageGrabber implementation, but will need to adapt it to the different API. You can not specify the path for the image file, for instance. The following file documents the API:

If I use the generic wayland version (with the proper API) I get this error:
Invalid reply from DBus: The name org.freedesktop.portal.Screenshot was not provided by any .service files
EDIT: the org.freedesktop.portal.Screenshot part of the ksnip app is not yet funcional.

That’s the interface name the method is exposed under: not the bus name. You want:

bus name: org.freedesktop.portal.Desktop
object path: /org/freedesktop/portal/desktop
interface: org.freedesktop.portal.Screenshot
method: Screenshot

I’m still a bit curious about how you’re accessing the gnome-shell screenshot API from your snap. I would have thought access would be blocked by the AppArmor restrictions, long before you’d be dealing with paths in /tmp.

There is an apparmor error, but I could work around it.
I can’t remeber which plug solved it but I added the dbus plug for the gnome api.
Then the only issue was the /tmp access.

Maybe you were using screencast-legacy? That won’t auto connect by default, so you’ll probably get a better experience with portals.

Assuming it does what you’re after, I would suggest using the portal API unconditionally for the snap version of your app.

It will handle both X11 and Wayland, and provides a consistent API for different Wayland compositors (i.e. with xdg-desktop-portal-kde installed, it will handle KDE desktops).