# Display, audio and desktop On Android, Droidspaces starts the Termux:X11 display server, the VirGL server and the PulseAudio server for you when the matching toggles are on, and sets `DISPLAY`, `GALLIUM_DRIVER` and `PULSE_SERVER` inside the container. Turn on the toggles, start the container, and graphical programs open in the Termux:X11 app with sound from the phone's speaker. This page covers the one-time setup, the three ways to render, sound, a desktop that starts at boot, and the Linux side. For a Wayland desktop such as KDE Plasma there is a second path, covered on the [Anland](Anland.md) page. > [!IMPORTANT] > Droidspaces does not ship Termux:X11, VirGL or PulseAudio. They are Termux packages. Droidspaces starts and stops them and bridges their sockets into the container. ## One-time setup on Android 1. Install the [Termux](https://github.com/termux/termux-app) and [Termux:X11](https://github.com/termux/termux-x11) apps. Get both from the same source, F-Droid or GitHub, so they are signed by the same key. 2. In Termux, run the setup script. It installs Termux:X11, VirGL and PulseAudio into Termux and patches PulseAudio's configuration for Android's audio stack: ```bash curl -fsSL https://github.com/ravindu644/Droidspaces-OSS/raw/refs/heads/main/scripts/setup-termux.sh | bash ``` That is all. You do not start anything in Termux yourself afterwards. > [!TIP] > The official XFCE images in the repository start XFCE on their own. Install one, turn on **Configure Termux:X11**, start the container and open the Termux:X11 app. The desktop is there. The [auto-boot section](#a-desktop-that-starts-at-boot) explains how it is wired, in case you want the same for another desktop. The display variables are set for login shells through `/etc/profile.d`. In `zsh`, `fish` or another shell that skips it, run `source /run/droidspaces.env` once after the container boots. ## Three ways to render on Android | | Works on | Speed | Toggles | |---|---|---|---| | **llvmpipe** | every device | software rendering, fine for a desktop and 2D apps | Configure Termux:X11 | | **VirGL** | Mali, PowerVR and other non-Qualcomm GPUs | hardware accelerated through a bridge in Termux | Configure Termux:X11 and Configure VirGL 3D Acceleration | | **Turnip** | Qualcomm Adreno | near native, the GPU is driven from inside the container | GPU Access and Configure Termux:X11, VirGL off | ### llvmpipe Turn on **Configure Termux:X11** in the container's configuration and start the container. When the Termux:X11 app shows its X-shaped cursor, the server is ready. Inside the container, `glxgears` or `startxfce4` opens in Termux:X11. Nothing else to set up, and no hardware access needed. ### VirGL Turn on **Configure Termux:X11** and **Configure VirGL 3D Acceleration**, then start the container. OpenGL calls in the container are sent to the VirGL server in Termux, which runs them on the phone's GPU. `glxinfo | grep renderer` inside the container names VirGL when it is working. If VirGL fails to start, put `--angle-vulkan` in the **VirGL Extra Flags** field to switch it to the Vulkan backend. ### Turnip Turnip is Mesa's open source Vulkan driver for Adreno, and with Zink on top it gives OpenGL as well. The container talks to the GPU directly, so it needs the GPU nodes and a Mesa build with Turnip. 1. Install Mesa with Turnip inside the container, following [Mesa for Android Container](https://github.com/lfdevs/mesa-for-android-container). 2. In the container's configuration, turn on **GPU Access** and **Configure Termux:X11**, and make sure **Configure VirGL 3D Acceleration** is off. 3. Add two variables in **Environment Variables** under **Advanced Options**: ``` MESA_LOADER_DRIVER_OVERRIDE=kgsl TU_DEBUG=noconform ``` 4. Start the container. Graphical programs now render on the GPU. A user other than root needs to be in the `droidspaces-gpu` group to open the GPU nodes: `usermod -aG droidspaces-gpu ` inside the container. ## Sound on Android Turn on **Configure PulseAudio** and start the container. Droidspaces starts a PulseAudio server in Termux, where Android's audio system allows it to play, sets Android's AAudio output as its default, mounts its socket into the container at `/tmp/.pulse-socket` and sets `PULSE_SERVER`. Anything that uses PulseAudio or PipeWire's PulseAudio compatibility plays through the phone. `paplay file.wav` is a quick test, and `pactl info` shows the connection. Whether sound works at all depends on the phone: the Android version, the vendor's audio HAL and the Termux PulseAudio build. On Samsung One UI 6.1 and newer, Droidspaces preloads a library the audio module needs; nothing to do on your side. ## A desktop that starts at boot Droidspaces waits for the X server's socket and mounts it into the container at `/tmp/.X11-unix/X5` before the container's init starts, so a systemd unit can start a desktop without racing it. The official XFCE images ship such a unit; the same pattern works for any desktop. The unit, `/etc/systemd/system/xfce-autostart.service`: ```ini [Unit] Description=XFCE Autostart After=graphical.target [Service] Type=simple User=root ExecCondition=/bin/sh -c "grep -q 'enable_x11=1' /run/droidspaces/container.config" ExecCondition=/bin/sh -c "test -S /tmp/.X11-unix/X5" ExecStart=/usr/local/bin/xfce-start Restart=on-failure [Install] WantedBy=graphical.target ``` The two conditions keep the unit quiet when Termux:X11 is off or the socket is missing: systemd skips it instead of failing. The launcher, `/usr/local/bin/xfce-start`, loads `/run/droidspaces.env`, falls back to `DISPLAY=:5`, and starts `startxfce4` as root or as the user named in `XFCE_USER`. Copy it from the [rootfs builder](https://github.com/Droidspaces/Droidspaces-rootfs-builder/blob/38907ca0b03aa77b1cbcdbcbe4c713accd45bbe8/scripts/xfce-start) that makes the official images. To run the desktop as a normal user, create one in the container with `useradd -m ` and set `XFCE_USER=` under **Environment Variables** in the container's configuration. The launcher hands that user the X, PulseAudio and VirGL sockets and passes the environment into the session. For another desktop, copy both files under new names, replace `startxfce4` in the launcher with the desktop's start command, such as `startplasma-x11`, and enable the unit with `systemctl enable`. The variable name `XFCE_USER` is only a convention; call it what you like. ## Linux On a Linux host, GPU acceleration needs no bridge: the container uses the host's GPU through Mesa like any other program. 1. Start the container with `--hw-access`, or `--gpu` for the GPU nodes alone. 2. Allow the container to reach your X server: `xhost +local:` on the host. 3. Add `--x11`, which mounts the host's X socket `/tmp/.X11-unix/X0`, and set `DISPLAY=:0` in the container's environment file (`--env`). Graphical programs started in the container then open on your desktop with hardware acceleration. Sound goes through the host's own PulseAudio or PipeWire socket if you bind-mount it; Droidspaces does not manage audio on Linux. --- Previous: [Command line reference](Linux-CLI.md) | Next: [Anland](Anland.md)