<a id="exp-desktop-interface"></a>

# Desktop interface

<!-- @artefact desktop interface -->

The desktop interface
provides access to the host system’s display (Wayland/X11) socket(s)
from inside the workshop,
allowing it to securely run GUI applications.

By using the interface,
the SDK publisher allows the workshop to utilize the host’s display
which can be useful for various SDK-specific tasks
such as building graphical applications or using editors without remote support.

<a id="exp-desktop-plug"></a>

## Desktop interface plug

An essential element here is the desktop interface plug,
which is declared in the SDK definition.

Its structure includes just the name of the plug and the interface;
both must be set to `desktop`.

Defining the plug in an SDK
allows the workshops using this SDK to access the host’s display,
which can be useful for various SDK-specific tasks
such as building graphical applications or using editors without remote support.

<a id="exp-desktop-slot"></a>

## Desktop interface slot

To let SDKs in a workshop access the host’s display,
**Workshop** provides a desktop interface slot
that multiple desktop interface plugs can access.

When the SDK is installed at runtime during launch and refresh operations,
**Workshop** checks that the plug targeting the slot
passes [validation](https://ubuntu.com/workshop/docs//explanation/interfaces/concepts.md#exp-interfaces-validation);
if it does,
it can be connected.

## Connection

The interface isn’t connected automatically at launch and refresh
for security reasons.
The **workshop connect** and **workshop disconnect** commands
can be invoked manually after the workshop has started:

<!-- @artefact workshop connect -->
<!-- @artefact workshop disconnect -->
```console
$ workshop connect ws/desktop-sdk:desktop
$ workshop disconnect ws/desktop-sdk:desktop
```

Establishing a connection means
a proxy Unix domain socket has been created
and the following environment variables have been set:

| Wayland                                                                                                                                                                    | X11                                                                                                                                                                                                         | Both                                                                                                                                                                                                                                         |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `$WAYLAND_DISPLAY`<br/><br/><br/>`$XDG_SESSION_TYPE`<br/><br/><br/>`$QT_QPA_PLATFORM`<br/><br/><br/>`$ELECTRON_OZONE_PLATFORM_HINT`<br/><br/><br/>`$XDG_BACKEND`<br/><br/> | `$DISPLAY`<br/><br/><br/>`$XDG_SESSION_TYPE`<br/><br/><br/>`$QT_QPA_PLATFORM`<br/><br/><br/>`$ELECTRON_OZONE_PLATFORM_HINT`<br/><br/><br/>`$XDG_BACKEND`<br/><br/><br/>`$XAUTHORITY`<sub>\*</sub><br/><br/> | `$WAYLAND_DISPLAY`<br/><br/><br/>`$DISPLAY`<br/><br/><br/>`$XDG_SESSION_TYPE`<br/><br/><br/>`$QT_QPA_PLATFORM`<br/><br/><br/>`$ELECTRON_OZONE_PLATFORM_HINT`<br/><br/><br/>`$XDG_BACKEND`<br/><br/><br/>`$XAUTHORITY`<sub>\*</sub><br/><br/> |

 *\*only set if present on the host*

To check if the interface is connected:

<!-- @artefact workshop connections -->
```console
$ workshop connections --all

  INTERFACE  PLUG                   SLOT                NOTES
  ...
  desktop    ws/desktop-sdk:desktop ws/system:desktop   manual
```

This means the host’s display socket (Wayland, X11 or both) is available inside the workshop:

<!-- @artefact workshop shell -->
```console
$ workshop shell ws
workshop@ws-8584e571$ ls $XDG_RUNTIME_DIR | grep wayland

  wayland-1
```

```console
$ workshop shell ws
workshop@ws-8584e571$ ls /tmp/.X11-unix

  X0
```

## See also

Explanation:

- [Interface concepts](https://ubuntu.com/workshop/docs//explanation/interfaces/concepts.md#exp-interface-concepts)
- [Plugs and slots](https://ubuntu.com/workshop/docs//explanation/interfaces/concepts.md#exp-plugs-slots)
- [SDK definition](https://ubuntu.com/workshop/docs//explanation/sdks/concepts.md#exp-sdk-definition)
- [Workshop definition](https://ubuntu.com/workshop/docs//explanation/workshops/concepts.md#exp-workshop-definition)

Reference:

- [workshop connect](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-connect)
- [workshop connections](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-connections)
- [workshop disconnect](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-disconnect)
- [workshop launch](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-launch)
- [workshop refresh](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-refresh)
- [workshop shell](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-shell)
