| 1 |
Writing a New Backend |
| 2 |
===================== |
| 3 |
|
| 4 |
Portal backends are session services that provide user interfaces, and access |
| 5 |
APIs and resources specific to the desktop environment they are running. For |
| 6 |
example, the KDE backend may use KDE-specific technologies, toolkit, and APIs. |
| 7 |
|
| 8 |
For a new portal backend (let's call it ``foo``) to be discoverable by XDG |
| 9 |
Desktop Portal, the following steps are necessary: |
| 10 |
|
| 11 |
* Implement one or more :doc:`backend D-Bus interfaces <impl-dbus-interfaces>` |
| 12 |
in an executable. This executable must be `D-Bus activatable |
| 13 |
<https://specifications.freedesktop.org/desktop-entry-spec/1.1/ar01s07.html>`_. |
| 14 |
* Install ``foo.portal`` file under ``{DATADIR}/xdg-desktop-portal/portals``. |
| 15 |
Usually, ``{DATADIR}`` is ``/usr/share``. The syntax of the portal file is |
| 16 |
documented below. |
| 17 |
* Make sure the new backend is picked by XDG Desktop Portal by adding a config |
| 18 |
file that points to the new ``foo`` portal backend. The syntax of the config |
| 19 |
file is documented below. |
| 20 |
|
| 21 |
Portal (`.portal`) File |
| 22 |
----------------------- |
| 23 |
|
| 24 |
Portal files are files that allow XDG Desktop Portal to know which portal |
| 25 |
backends are available, and which backend D-Bus interfaces they implement. |
| 26 |
They usually look like this: |
| 27 |
|
| 28 |
.. code-block:: |
| 29 |
|
| 30 |
[portal] |
| 31 |
DBusName=org.freedesktop.impl.portal.desktop.foo |
| 32 |
Interfaces=org.freedesktop.impl.portal.AppChooser;org.freedesktop.impl.portal.Background;org.freedesktop.impl.portal.Clipboard;org.freedesktop.impl.portal.FileChooser;org.freedesktop.impl.portal.Lockdown;org.freedesktop.impl.portal.RemoteDesktop;org.freedesktop.impl.portal.ScreenCast; |
| 33 |
UseIn=gnome |
| 34 |
|
| 35 |
The following keys are supported in this file: |
| 36 |
|
| 37 |
* ``DBusName``: the D-Bus activation name of the portal backend service. |
| 38 |
* ``Interfaces``: which :doc:`backend D-Bus interfaces <impl-dbus-interfaces>` |
| 39 |
this portal backend implements. |
| 40 |
* ``UseIn``: which desktop environments the portal backend should run. **This |
| 41 |
key is officially deprecated, and has been replaced by the config file**, but |
| 42 |
it's recommended to keep it there for legacy systems. |