Skip to content

Commit 73fceb7

Browse files
bqueninclaude
andauthored
Use D-Bus portal detection instead of WAYLAND_DISPLAY env var (#206)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2f99d38 commit 73fceb7

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dependencies = [
3939
# Linux only - window capture (X11 fallback)
4040
"python-xlib>=0.33; sys_platform == 'linux'",
4141
# Linux only - window capture (Wayland via PipeWire portal)
42-
"pipewire-capture>=0.2.6; sys_platform == 'linux'",
42+
"pipewire-capture>=0.2.8; sys_platform == 'linux'",
4343
# GPU acceleration (CUDA 12) - Windows and Linux
4444
"nvidia-cublas-cu12; sys_platform == 'win32' or sys_platform == 'linux'",
4545
"nvidia-cudnn-cu12; sys_platform == 'win32' or sys_platform == 'linux'",

src/interpreter/capture/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def stop(self) -> None:
7171
)
7272

7373
CaptureStream = MacOSCaptureStream
74+
_is_wayland_session = False
7475

7576
def is_window_foreground(window_id: int) -> bool:
7677
# TODO: Implement for macOS if needed
@@ -88,9 +89,12 @@ def is_window_foreground(window_id: int) -> bool:
8889
)
8990

9091
CaptureStream = WindowsCaptureStream
92+
_is_wayland_session = False
9193
elif _system == "Linux":
92-
# Detect session type: Wayland or X11
93-
_is_wayland_session = bool(os.environ.get("WAYLAND_DISPLAY"))
94+
# Detect session type: check if PipeWire portal is available (works on gamescope/Steam Deck)
95+
from pipewire_capture import is_available as _pipewire_available
96+
97+
_is_wayland_session = _pipewire_available()
9498

9599
if _is_wayland_session:
96100
# Wayland session: use pipewire-capture

src/interpreter/gui/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ def run():
138138
log.configure(level="DEBUG" if args.debug else "INFO")
139139

140140
# Configure pipewire-capture logging on Wayland (must be after log.configure)
141-
if platform.system() == "Linux" and os.environ.get("WAYLAND_DISPLAY"):
141+
from ..capture import _is_wayland_session
142+
143+
if _is_wayland_session:
142144
from ..capture.linux_wayland import configure_logging as configure_wayland_logging
143145

144146
configure_wayland_logging(args.debug)

src/interpreter/gui/main_window.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
)
2525

2626
from .. import log
27-
from ..capture import Capture, WindowCapture
27+
from ..capture import Capture, WindowCapture, _is_wayland_session
2828
from ..capture.convert import bgra_to_rgb_pil
2929
from ..config import Config, OverlayMode
3030
from ..overlay import BannerOverlay, InplaceOverlay
@@ -69,8 +69,8 @@ def __init__(self, config: Config):
6969
self._mode = config.overlay_mode
7070
self._windows_list: list[dict] = []
7171
self._paused = False
72-
# Detect session type: Wayland or X11-only
73-
self._is_wayland_session = bool(os.environ.get("WAYLAND_DISPLAY"))
72+
# Wayland session detection (from capture module, uses D-Bus portal check)
73+
self._is_wayland_session = _is_wayland_session
7474
self._wayland_portal = None # WaylandPortalCapture instance (for managing portal session lifecycle)
7575
self._wayland_selecting = False # Guard against re-entry during portal flow
7676
self._fixing_ocr = False # Track if we're re-downloading OCR model
@@ -257,7 +257,7 @@ def _setup_ui(self):
257257
overlay_layout.addWidget(self._mode_hotkey)
258258

259259
# Wayland limitation warning (only shown on Wayland)
260-
if os.environ.get("WAYLAND_DISPLAY"):
260+
if self._is_wayland_session:
261261
wayland_warning = QLabel("<a href='#' style='color: #ffa500;'>⚠️ Wayland limitations</a>")
262262
wayland_warning.setToolTip("Click for details about inplace mode on Wayland")
263263
wayland_warning.linkActivated.connect(self._show_wayland_warning)

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)