Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Flatpak not supporting wayland screenshots #390

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

Closed
DamirPorobic opened this issue Jul 28, 2020 · 38 comments
Closed

Flatpak not supporting wayland screenshots #390

DamirPorobic opened this issue Jul 28, 2020 · 38 comments
Assignees
Labels

Comments

@DamirPorobic
Copy link
Member

For wayland support under flatpak we need to use different dbus, this needs to be fixed as we currently use the Gnome and Plasma dbus interfaces.

@DamirPorobic
Copy link
Member Author

@LyzardKing FYI

@bilelmoussaoui
Copy link

You can run the flatpak with --log-session-bus and see which dbus server it tries to communicate with

@DamirPorobic
Copy link
Member Author

@bilelmoussaoui thanks for the tip, will try that later. I know already that under Gnome the call should go to org.gnome.Shell.Screenshot and under Plasma it should go to org.kde.kwin.Screenshot but probably both wont work in flatpaks and snaps so I started writing one that calls org.freedesktop.portal.Screenshot when in flatpaks and snaps but my first test yesterday under snap gave me an error message saying that the service was unknown. Should such a call work under flatpak?

Bit of topic, how can I detected from code if I'm running in flatpak? With snaps I can check if the $SNAP variable is set, is there such a variable with flatpaks?

@DamirPorobic DamirPorobic self-assigned this Jul 31, 2020
@bilelmoussaoui
Copy link

@bilelmoussaoui thanks for the tip, will try that later. I know already that under Gnome the call should go to org.gnome.Shell.Screenshot and under Plasma it should go to org.kde.kwin.Screenshot but probably both wont work in flatpaks and snaps so I started writing one that calls org.freedesktop.portal.Screenshot when in flatpaks and snaps but my first test yesterday under snap gave me an error message saying that the service was unknown. Should such a call work under flatpak?

Bit of topic, how can I detected from code if I'm running in flatpak? With snaps I can check if the $SNAP variable is set, is there such a variable with flatpaks?

You can check if /.flatpak-info file exists

@DamirPorobic DamirPorobic removed their assignment Aug 2, 2020
@DamirPorobic
Copy link
Member Author

Actually, this seems to be working. I've just tested Plasma Wayland and was able to take screenshots with the ksnip flatpak. The Default kwin dbus was used.

@DamirPorobic DamirPorobic added no_issue and removed bug labels Aug 2, 2020
@DamirPorobic DamirPorobic self-assigned this Aug 2, 2020
@DamirPorobic
Copy link
Member Author

Reopening this ticket as screenshots seem to be not working under Gnome.

@DamirPorobic DamirPorobic reopened this Aug 2, 2020
@DamirPorobic DamirPorobic added bug and removed no_issue labels Aug 2, 2020
@DamirPorobic
Copy link
Member Author

@bilelmoussaoui I have tried calling the Gnome DBus that works outside Snaps and Flatpaks and got this:
image

The other thing that I tried to achieve is using the general org.freedesktop.portal.Screenshot that according to the flatpak docu should be available but I only get those errors.
image

@bilelmoussaoui
Copy link

Do you have xdg-desktop-portal installed?

@DamirPorobic
Copy link
Member Author

I guess not, it goes into the manifest file? This is our https://github.com/flathub/org.ksnip.ksnip/blob/master/org.ksnip.ksnip.yaml

@bilelmoussaoui
Copy link

The xdg-desktop-portal is needed on the host if you want to use the portals. It's a generic thing that hopefully snap will support as well in the future.

@DamirPorobic
Copy link
Member Author

Is installing the portal on the host enough or do I need to change something in the manifest?

@DamirPorobic
Copy link
Member Author

Looks like it was already installed on the host system.

@bilelmoussaoui
Copy link

The manifest doesn't seem to ask for the permission to talk to the GNOME screenshot dbus service. The kde one is included in the org.kde.* which is sadly needed for working tray icons

@DamirPorobic
Copy link
Member Author

Ok, I need to add permission to speak to the GNOME Screenshot dbus service, I'll look into that.

Though still don't understand why org.freedesktop.portal.Screenshot isn't working, xdg-desktop-portal is was definitely installed
on the machine, maybe I'm missing permission there too?

How should those permissions look like? Something like:

  - --talk-name=org.gnome.Shell.Screenshot.*
  - --talk-name=org.freedesktop.portal.Screenshot

@LyzardKing
Copy link
Contributor

@DamirPorobic you can test adding new permissions without reinstalling:
flatpak run --talk-name=org.gnome.Shell.Screenshot.* --talk-name=org.freedesktop.portal.Screenshot org.ksnip.ksnip

@DamirPorobic
Copy link
Member Author

Thanks, will try that tonight, this will definitely speed things up.

@LyzardKing
Copy link
Contributor

But with those additions I still get the error:
"Unable to show image: No image provided to but one was expected."

@DamirPorobic
Copy link
Member Author

DamirPorobic commented Aug 3, 2020

Well thats more then I had, I had only errors from the DBus, what you have there is a ksnip error that comes after the dbus call.

Addition: Gnome Wayland works a bit different then Plasma Wayland in regards to screenshots. Gnome save a new Screenshot to a temporary location/file and we fetch it from there, maybe the next issue is that we have no write or read permission for the directory.

@LyzardKing
Copy link
Contributor

LyzardKing commented Aug 3, 2020

EDIT:
it works if you add the permission --filesystem=/tmp

@LyzardKing
Copy link
Contributor

I'll edit the yaml file with the necessary permissions.
It might be a bit too loose with the permissions, since it could be able to read anything from /tmp.
But for now, if the portal doesn't support it automatically..at least it works.

@LyzardKing
Copy link
Contributor

The last remaining issues are that if we enable wayland to display the application, it will not render the close button in the menu (just a blank menu).
And the appindicator will not work with wayland. But we could use xwayland to display the applicaiton.

@DamirPorobic
Copy link
Member Author

Yes, it's the /tmp directory, we always save in format /tmp/ksnip-{RANDOM-NUMBER}.png

@DamirPorobic
Copy link
Member Author

it will not render the close button in the menu (just a blank menu).

What close button?

And the appindicator will not work with wayland. But we could use xwayland to display the applicaiton.

You could try if that works. Any drawbacks?

@LyzardKing
Copy link
Contributor

The exit button... in the top menu.
xwayland seems to work properly atm.

@LyzardKing
Copy link
Contributor

image

@LyzardKing
Copy link
Contributor

On xwayland:
image

@DamirPorobic
Copy link
Member Author

hmm, strange that this is not working, it's a basic functionality of the window manager.

@DamirPorobic
Copy link
Member Author

Then go with xwayland?

@LyzardKing
Copy link
Contributor

Done.
For the moment I uploaded with xwayland.
If we fix it it should be enough to add --socket=wayland

@LyzardKing
Copy link
Contributor

The new portal API should not need to use the system /tmp folder.
So while this now works, it does not work properly.
A revision of the new API screenshot part is necessary

@LyzardKing
Copy link
Contributor

Why is is this command running the x11 code?
flatpak run --env=XDG_SESSION_TYPE=wayland --env=XDG_CURRENT_DESKTOP=foo org.ksnip.ksnip
I want to use the "generic" wayland one. That should/could be the one that works in the snap/flatpak

@DamirPorobic
Copy link
Member Author

With new API you mean org.freedesktop.portal.Screenshot? Need to make that work first, so far I haven't been able to test i but I haven tested the permission stuff. For now we should go with both solutions, the portal API is a bit limited if get that correctly, there seems to be less screenshot capabilities. Also, I think it works similar by creating a file in some directory that we can then fetch, but I guess it's a different directory.

@DamirPorobic
Copy link
Member Author

Why is is this command running the x11 code?
flatpak run --env=XDG_SESSION_TYPE=wayland --env=XDG_CURRENT_DESKTOP=foo org.ksnip.ksnip
I want to use the "generic" wayland one. That should/could be the one that works in the snap/flatpak

The generic one is just a DBus call without handling of the result yet, you can't see any screenshot with it. Only the Snap package resolved to the generic one I guess. Try to set the $SNAP variable to any dummy value.

@LyzardKing
Copy link
Contributor

Ah ok. So the only way for the snap to work in wayland is to add the freedesktop portal variant.
It cannot (unlinke the flatpak) have full access over the /tmp folder.
So for now the flatpak works with the old API, the snap is not.

@DamirPorobic
Copy link
Member Author

DamirPorobic commented Aug 3, 2020

Yes, Snap has also the problem that it can't figure out if it's running in Gnome, I have found the issue but haven't fixed it yet, hopefully tonight.

Snap Wayland:
New API -> Not Working
Old API -> Not Working

Flatpak Wayland
New API -> Not Working
Old API -> Working

We have for the Snap issue a separate ticket.

@LyzardKing
Copy link
Contributor

Yes, Snap has also the problem that it can't figure out if it's running in Gnome, I have found the issue but haven't fixed it yet, hopefully tonight.

This is solved if we remove the XDG_CURRENT_DESKTOP from the snap yaml. We introduced it as a workaround, but it seems to work fine without it now.

@DamirPorobic
Copy link
Member Author

Oh, we set that to Unity? We don't need that part anymore?

@DamirPorobic
Copy link
Member Author

I would suggest we close this issue and work in #389 on the Snap Wayland issue.

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

No branches or pull requests

3 participants