Using xdg-desktop-portal-kde to take screenshots

Damir Porobic damir_porobic at live.com
Mon Sep 21 09:31:33 BST 2020


When you run "dbus-monitor --session" and you perform the screenshot, do you see this signal to be called at all?

Thanks Jan, I'll try that.

Unfortunately no, again a limitation of the portal API as the portal is supposed to return an URI. You can however directly use KWin DBus interface to get a screenshot, specifying directly what type of screenshot you want to tak and you get the raw image. This however will make it work only in Plasma and will not work in an application running in sandbox without giving it access to DBus.
My Application already supports native Plasma and Gnome Wayland Screenshots, but that does don't work if the application is packaged as Snap or when non Plasma or Gnome environments are used, so I'm trying to make this generic  Wayland solution work.

Also, I've been playing around with this under Gnome too and they have also a Dialog but with a Share button instead of Save. I believe they are doing it like with the native Wayland solution by saving the image in a temp directory that is deleted on reboot and just providing the path to the image. The user can decide what to do with the image, save it permanently or do nothing and the image is gone. Though there I have the same problem that the gotScreenshotResponse is never called.

Best regards,
Damir

________________________________
From: kde-devel <kde-devel-bounces at kde.org> on behalf of Jan Grulich <jgrulich at redhat.com>
Sent: Monday, September 21, 2020 08:08
To: kde-devel at kde.org <kde-devel at kde.org>
Subject: Re: Using xdg-desktop-portal-kde to take screenshots

Hi,

ne 20. 9. 2020 v 18:37 odesílatel Damir Porobic <damir_porobic at live.com<mailto:damir_porobic at live.com>> napsal:
Hello Jan,

finally I  found some time to upgrade my OS and got a newer Plasma Version but I'm still struggling with the Screenshot Portal.

Here is my implementation, almost identical to yours from the test that you have linked me (pasting here only the relevant methods):I get the dialog which asks me what type of screenshot I want to take I select it, a small image is show in the dialog and I can click on save (which saves the image in my home directory) but the gotScreenshotResponse is never called. Any idea why?

I have no idea. The code looks good and identical to what I have in the example. When you run "dbus-monitor --session" and you perform the screenshot, do you see this signal to be called at all?

Can I tell the dialog where to save those images?

Unfortunately no, I made it very basic, but patches are welcomed, it won't be a hard task to implement it.

Can I tell the dialog right away what type of screenshot I want to take?

Unfortunately no, this is not supported by the portal API.

Can I just share the screenshot with my application without saving it?

Unfortunately no, again a limitation of the portal API as the portal is supposed to return an URI. You can however directly use KWin DBus interface to get a screenshot, specifying directly what type of screenshot you want to tak and you get the raw image. This however will make it work only in Plasma and will not work in an application running in sandbox without giving it access to DBus.

Regards,
Jan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-devel/attachments/20200921/f4bac3e9/attachment.htm>


More information about the kde-devel mailing list