From 83e3cdef3338a65c66fcf9ad76bf07d1f039faa9 Mon Sep 17 00:00:00 2001 From: dev Date: Mon, 23 Feb 2026 12:57:59 +0000 Subject: [PATCH] feat(entry): implement def validate_wayland_environment --- scanslicer/entry.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scanslicer/entry.py b/scanslicer/entry.py index f38d69e..4f903b9 100644 --- a/scanslicer/entry.py +++ b/scanslicer/entry.py @@ -97,3 +97,20 @@ def configure_qt_backend(backend): # settings when available (for example dark/light mode). if os.path.exists("/.dockerenv"): os.environ.setdefault("QT_QPA_PLATFORMTHEME", "gtk3") + + +# validate_wayland_environment: function definition for ScanSlicer behavior. +def validate_wayland_environment(): + runtime_dir = os.environ.get("XDG_RUNTIME_DIR", "").strip() + display_name = os.environ.get("WAYLAND_DISPLAY", "").strip() + if not runtime_dir or not display_name: + raise RuntimeError( + "Missing Wayland runtime environment. " + "Set XDG_RUNTIME_DIR and WAYLAND_DISPLAY." + ) + + socket_path = os.path.join(runtime_dir, display_name) + if not os.path.exists(socket_path): + raise RuntimeError( + f"Wayland socket not found: {socket_path}" + )