feat(entry): implement def resolve_runtime_backend
This commit is contained in:
parent
052d3efefa
commit
fff9178f8a
1 changed files with 27 additions and 0 deletions
|
|
@ -36,3 +36,30 @@ def _detect_backend_from_qpa_env():
|
|||
if token in ("xcb", "x11"):
|
||||
return "x11"
|
||||
return None
|
||||
|
||||
|
||||
# resolve_runtime_backend: function definition for ScanSlicer behavior.
|
||||
def resolve_runtime_backend(backend):
|
||||
if backend in ("wayland", "x11"):
|
||||
return backend
|
||||
|
||||
env_backend = _detect_backend_from_qpa_env()
|
||||
if env_backend is not None:
|
||||
return env_backend
|
||||
|
||||
session_type = os.environ.get("XDG_SESSION_TYPE", "").strip().lower()
|
||||
if session_type == "wayland":
|
||||
return "wayland"
|
||||
if session_type == "x11":
|
||||
return "x11"
|
||||
|
||||
runtime_dir = os.environ.get("XDG_RUNTIME_DIR", "").strip()
|
||||
wayland_display = os.environ.get("WAYLAND_DISPLAY", "").strip()
|
||||
if runtime_dir and wayland_display and os.path.exists(os.path.join(runtime_dir, wayland_display)):
|
||||
return "wayland"
|
||||
|
||||
if os.environ.get("DISPLAY", "").strip():
|
||||
return "x11"
|
||||
|
||||
# Fall back to Wayland when auto-detection has no clear signal.
|
||||
return "wayland"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue