From 40edf8e1e1b13ccbd246774eeae1b5a3fd892ab3 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 15 Nov 2026 00:58:03 +0900 Subject: [PATCH] refac --- open_terminal/desktop_portal.py | 2 +- open_terminal/desktop_wayland.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/open_terminal/desktop_portal.py b/open_terminal/desktop_portal.py index 541e79a..e04c4e0 100644 --- a/open_terminal/desktop_portal.py +++ b/open_terminal/desktop_portal.py @@ -334,7 +334,7 @@ class PortalDesktop(NativeDesktop): try: await asyncio.wait_for(self.first_frame.wait(), 15) except TimeoutError as exc: - raise RuntimeError("PipeWire capture produced no screen frame within 15 seconds. Check that the shared desktop is unlocked and PipeWire is running." + self.capture_error()) from exc + raise RuntimeError("PipeWire capture produced no screen frame within 15 seconds." + self.capture_error()) from exc self.grab() async def read_stderr(self, process): diff --git a/open_terminal/desktop_wayland.py b/open_terminal/desktop_wayland.py index 182c267..f10c68a 100644 --- a/open_terminal/desktop_wayland.py +++ b/open_terminal/desktop_wayland.py @@ -31,6 +31,7 @@ class WaylandDesktop(PortalDesktop): self.owner = None self.stream_path = None self.node_ready = asyncio.Event() + self.services = {} self.width = self.screen_width = WIDTH self.height = self.screen_height = HEIGHT self.failure = "The virtual GNOME Wayland desktop has stopped. Reconnect to start a new session." @@ -67,6 +68,7 @@ class WaylandDesktop(PortalDesktop): start_new_session=True, stdout=output, stderr=output, ) self.processes.append(process) + self.services[name] = process return process async def wait_socket(self, name, process): @@ -112,7 +114,8 @@ class WaylandDesktop(PortalDesktop): await self.wait_socket("bus", daemon) pipewire = await self.launch("pipewire", "pipewire") await self.wait_socket("pipewire-0", pipewire) - await self.launch("wireplumber", "wireplumber") + # Only link our screen stream; leave physical devices to the host. + await self.launch("wireplumber", "wireplumber", "--profile=policy") compositor = await self.launch( "gnome", "gnome-shell", "--headless", "--wayland", f"--virtual-monitor={WIDTH}x{HEIGHT}", "--wayland-display=wayland-0", @@ -161,10 +164,12 @@ class WaylandDesktop(PortalDesktop): await self.start_capture(env=self.env) except Exception as exc: details = [] - for name in ("gnome", "pipewire", "dbus"): + for name in ("wireplumber", "gnome", "pipewire", "dbus"): path = self.runtime / f"{name}.log" if path.exists(): - details.append(f"{name}: {path.read_text(errors='replace')[-1500:]}") + process = self.services.get(name) + status = f" (exit {process.returncode})" if process and process.returncode is not None else "" + details.append(f"{name}{status}: {path.read_text(errors='replace')[-1500:]}") raise RuntimeError(f"Could not start virtual GNOME Wayland: {exc}\n" + "\n".join(details)) from exc async def notify(self, member, signature, *body):