Skip to content

Use XDG Desktop Portals on Linux instead of screenshot tools #1010

@liferooter

Description

@liferooter

The application needs an ability to scan QR code from screen, but arbitrary reading from screen is not supported on Wayland for security reasons. But an ability to get screen content when needed is needed sometimes. So there is an API for that. There is a generic API for permission-based access granting on Linux. It's called XDG Desktop Portals. There is a portal for taking screenshot.

It's already used in some apps for the same thing. For example, Authenticator, an application for generating two-factor codes, uses the portal to scan QR code.

There are some advantages of this way to scan QRs from the screen:

  • Universality. The portal will work on every desktop environment that support it. Your current hack using GNOME Screenshot and Spectacle requires GNOME Screenshot and Spectacle to be installed and also only works on GNOME and KDE, but the portal works on GNOME, KDE, Elementary, wlroots-based WMs and every desktop environment that supports or will support the portal.
  • Sandboxability. The portal works well with sandboxing systems like Flatpak and Snap, so the application will be able to work without unrestricted access to the host system.
  • Consistency. You won't need to use different parts of code for different Linux desktop environments since the portal API is unified.
  • Availability. GNOME Screenshot and Spectacle can be or not bet installed on the machine. But XDG Desktop Portals is very common and standard thing that is usually installed on every Linux computer.
  • Long-term support: Your current hack with GNOME Screenshot and Spectacle supposes that these tools won't change their CLI and behavior. But they can, since they're not designed as any kind of public API. The portal API is a public API that is expected to be stable and supported since applications are expected to use it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions