DBus service for screenshots.

Boudhayan Gupta bgupta at kde.org
Fri Sep 25 09:37:29 PDT 2015


> So what's the expected flow here? You don't have any way of providing
> a filename to the Agent for further manipulation and publishing. Is
> the Agent expected to show all recently taken thumbnails in a grid or
> similar, and have the user select them? What's the expectation here?

I think we're having a bit of a misunderstanding here. The interface
that I've proposed here is simply for activation purposes. It's not a
comprehensive communication protocol between the compositor and the
screenshooting agent.

I'll explain with an use-case. In KDE, a component called KHotkeys
(which is a daemon in its own right in X11 and a component (shared
library inside) of KWin in Wayland, manages global hotkeys. KHotkeys
is configured to invoke KSnapshot when the PrintScreen key is pressed.

Now that we've retired KSnapshot and are replacing it with a new tool,
we thought we could improve on invokation by not hardcoding a single
command (in KHotkeys or in a config file), but use D-Bus activation to
fire up the application implementing the org.freedesktop.Screenshot
service.

This is why the interface is like what it is - the methods FullScreen,
CurrentScreen, ActiveWindow and WindowUnderCursor simply fire up the
agent, instruct them to take the respective type of screenshot in the
background, and then exit the agent. The StartAgent method starts the
agent, but instead of doing anything in the background, pulls up the
UI.

If the interface is being provided by a compositor instead of directly
by an agent, the compositor isn't activated/deactivated, but the four
methods still take screenshots and save them with some default
filename without showing any UI (a notification may be shown, but how
to do that is at the discretion of the compositor/agent). In this
case, however, the StartAgent function pulls up an UI, which may be a
trusted app or simply some component integrated into the compositor.

It's an (admittedly elaborate) way of mapping keyboard shortcuts to
DBus methods and not commands. That way, swapping out screenshot tools
does not require re-mapping hotkeys in the DE.

The interface does not allow you to specify filenames or advanced
options by design - the filename is returned by the ScreenshotTaken
signal.

Once the agent has started, it is entirely at the agent's discretion
on how to obtain an image, which it may do by invoking the X11 APIs
directly, or using the compositor's DBus APIs (such as
org.kde.kwin.Screenshot or org.gnome.Shell.Screenshot).

Yours,
Boudhayan Gupta


More information about the xdg mailing list