diff --git a/README.md b/README.md index 035ea11..5260c84 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ pip install open-terminal open-terminal run --host 0.0.0.0 --port 8000 ``` -Linux defaults to a separate VNC desktop, preferring an installed GNOME X11 session and falling back to XFCE. On Ubuntu/Debian, install `sudo apt install tigervnc-standalone-server dbus-x11 x11-utils xauth xdotool scrot xclip` plus a supported desktop session (`gnome-session` or `xfce4 xfce4-terminal`), then restart Open Terminal. Keep your existing display manager if prompted. Docker `latest` includes XFCE and its dependencies. Sharing your actual logged-in desktop requires `--desktop-mode host`; see [desktop setup](docs/configuration.md#desktop) for dependencies and Wayland support. +Linux defaults to a separate desktop, preferring GNOME and falling back to XFCE. GNOME supports Wayland-only systems, including Ubuntu 26.04; XFCE and older GNOME X11 sessions use VNC. See [desktop setup](docs/configuration.md#desktop) for the required packages. Keep your existing display manager if prompted during installation. Docker `latest` includes XFCE and its dependencies. Sharing your actual logged-in desktop requires `--desktop-mode host`. If no API key is configured, one is generated and printed at startup. For Docker, find it with `docker logs open-terminal`. diff --git a/docs/configuration.md b/docs/configuration.md index c2604a2..d337a97 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -42,8 +42,8 @@ open-terminal run --config /path/to/my-config.toml ## Desktop -Linux defaults to a **separate virtual desktop over VNC**. It prefers an installed -GNOME X11 session (including Ubuntu's GNOME session), otherwise uses XFCE. Docker +Linux defaults to a **separate virtual desktop**. It prefers installed GNOME, +otherwise uses XFCE. Docker `latest` includes XFCE. To choose explicitly: ```sh @@ -51,7 +51,22 @@ open-terminal run --desktop-environment gnome # Or: open-terminal run --desktop-environment xfce ``` -On bare-metal Ubuntu/Debian, install the VNC tools: +On **Ubuntu 26.04 and other Wayland-only GNOME installations**, install: + +```sh +sudo apt install gnome-shell dbus-daemon pipewire wireplumber gstreamer1.0-tools gstreamer1.0-pipewire gstreamer1.0-plugins-base libgl1-mesa-dri +open-terminal run --desktop-environment gnome +``` + +Open Terminal starts a headless GNOME Shell with its own virtual monitor, D-Bus +session, and PipeWire services. It works over SSH without a graphical login or +an on-screen permission prompt. It uses the same viewer, screenshots, and input +tools as other desktops. Commands launched through the API inherit this virtual +desktop's display and bus so Wayland apps open there. The logged-in host desktop +is not used. This backend currently requires single-user mode and does not stream +audio; use XFCE for multi-user deployments. It is tested with Ubuntu 26.04/GNOME 50. + +For **XFCE or older GNOME installations with an X11 session**, install the VNC tools: ```sh sudo apt install tigervnc-standalone-server dbus-x11 x11-utils xauth xdotool scrot xclip @@ -62,9 +77,9 @@ or `xfce4 xfce4-terminal`. Debian 13 packages GNOME's X11 session separately as `gnome-session-xsession`; install it as well when using GNOME there. Keep your existing display manager if the installer asks; Open Terminal starts its own session and does not need LightDM or GDM. -GNOME installations that only support Wayland cannot run inside TigerVNC; -auto selection uses XFCE instead. Explicit `gnome` selection reports an error -if the required X11 session is missing. Restart Open Terminal after installation. +When GNOME has no X11 session, Open Terminal selects the Wayland backend instead +of TigerVNC. Missing dependencies produce an error for the selected backend; +they never cause a connection to the host desktop. Restart after installation. To share **your actual logged-in desktop and its open windows**, opt in explicitly: @@ -87,7 +102,7 @@ From SSH, run as the same OS user: Open Terminal can reach that user's existing desktop portal even when `XDG_SESSION_TYPE=tty`. Someone must still be logged in to the graphical desktop and approve the dialog there. Host mode never starts a new desktop as a fallback. Wayland text input sends Unicode key events; audio -sharing is currently available only in virtual mode. +sharing is currently available only in VNC virtual sessions. The equivalent environment variables are `OPEN_TERMINAL_DESKTOP_MODE` (`virtual` or `host`) and `OPEN_TERMINAL_DESKTOP_ENVIRONMENT` diff --git a/open_terminal/desktop_portal.py b/open_terminal/desktop_portal.py index 825f81a..0a83e56 100644 --- a/open_terminal/desktop_portal.py +++ b/open_terminal/desktop_portal.py @@ -353,10 +353,12 @@ class PortalDesktop(NativeDesktop): await asyncio.gather(self.reader_task, return_exceptions=True) with contextlib.suppress(Exception): await self.stop_session() + if self.bus: + self.bus.disconnect() + with contextlib.suppress(Exception): + await self.bus.wait_for_disconnect() for process in reversed(self.processes): await self.stop_process(process) if self.stderr_task: self.stderr_task.cancel() await asyncio.gather(self.stderr_task, return_exceptions=True) - if self.bus: - self.bus.disconnect() diff --git a/open_terminal/desktop_wayland.py b/open_terminal/desktop_wayland.py index cc36b76..8d65b03 100644 --- a/open_terminal/desktop_wayland.py +++ b/open_terminal/desktop_wayland.py @@ -147,6 +147,14 @@ class WaylandDesktop(PortalDesktop): SCREENCAST, cast, SCREENCAST + ".Session", "RecordMonitor", "sa{sv}", ["", {"cursor-mode": Variant("u", 1)}], ))[0] + parameters = (await self.invoke( + SCREENCAST, self.stream_path, PROPERTIES, "Get", "ss", + [SCREENCAST + ".Stream", "Parameters"], + ))[0].value + size = parameters["size"].value + if len(size) != 2 or any(n <= 0 or n > 32767 for n in size): + raise RuntimeError("GNOME returned an invalid monitor size") + self.screen_width, self.screen_height = size self.input = PortalInput(self) await self.invoke(REMOTE, self.session, REMOTE + ".Session", "Start") await asyncio.wait_for(self.node_ready.wait(), 15)