prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Default to QT_QPA_PLATFORM=xcb on Linux/Wayland
  If we detect a linux box running on wayland, we should force Qt to use the xcb platform as the wayland backend doesn't work properly with moderngl.
  
  This maybe a good way to detect wayland:
  ```
  XDG_SESSION_TYPE=wayland
  ```
  
  Relevant discussions:
  - https://github.com/abey79/vsketch/issues/353
  - https://discord.com/channels/550302843777712148/696045774970028062/1072436292798926868
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `vpype_viewer/qtviewer/__init__.py`
  Content:
  ```
  1 from .viewer import *
  2
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/vpype_viewer/qtviewer/__init__.py b/vpype_viewer/qtviewer/__init__.py
  --- a/vpype_viewer/qtviewer/__init__.py
  +++ b/vpype_viewer/qtviewer/__init__.py
  @@ -1 +1,18 @@
  +def _check_wayland():
  +    """Fix QT env variable on Wayland-based systems.
  +
  +    See https://github.com/abey79/vpype/issues/596
  +    """
  +    import os
  +    import sys
  +
  +    if sys.platform.startswith("linux"):
  +        if os.environ.get("XDG_SESSION_TYPE", "") == "wayland":
  +            if "QT_QPA_PLATFORM" not in os.environ:
  +                os.environ["QT_QPA_PLATFORM"] = "xcb"
  +
  +
  +_check_wayland()
  +
  +
   from .viewer import *
  
verification_info: {"golden_diff": "diff --git a/vpype_viewer/qtviewer/__init__.py b/vpype_viewer/qtviewer/__init__.py\n--- a/vpype_viewer/qtviewer/__init__.py\n+++ b/vpype_viewer/qtviewer/__init__.py\n@@ -1 +1,18 @@\n+def _check_wayland():\n+    \"\"\"Fix QT env variable on Wayland-based systems.\n+\n+    See https://github.com/abey79/vpype/issues/596\n+    \"\"\"\n+    import os\n+    import sys\n+\n+    if sys.platform.startswith(\"linux\"):\n+        if os.environ.get(\"XDG_SESSION_TYPE\", \"\") == \"wayland\":\n+            if \"QT_QPA_PLATFORM\" not in os.environ:\n+                os.environ[\"QT_QPA_PLATFORM\"] = \"xcb\"\n+\n+\n+_check_wayland()\n+\n+\n from .viewer import *\n", "issue": "Default to QT_QPA_PLATFORM=xcb on Linux/Wayland\nIf we detect a linux box running on wayland, we should force Qt to use the xcb platform as the wayland backend doesn't work properly with moderngl.\r\n\r\nThis maybe a good way to detect wayland:\r\n```\r\nXDG_SESSION_TYPE=wayland\r\n```\r\n\r\nRelevant discussions:\r\n- https://github.com/abey79/vsketch/issues/353\r\n- https://discord.com/channels/550302843777712148/696045774970028062/1072436292798926868\n", "before_files": [{"content": "from .viewer import *\n", "path": "vpype_viewer/qtviewer/__init__.py"}], "after_files": [{"content": "def _check_wayland():\n    \"\"\"Fix QT env variable on Wayland-based systems.\n\n    See https://github.com/abey79/vpype/issues/596\n    \"\"\"\n    import os\n    import sys\n\n    if sys.platform.startswith(\"linux\"):\n        if os.environ.get(\"XDG_SESSION_TYPE\", \"\") == \"wayland\":\n            if \"QT_QPA_PLATFORM\" not in os.environ:\n                os.environ[\"QT_QPA_PLATFORM\"] = \"xcb\"\n\n\n_check_wayland()\n\n\nfrom .viewer import *\n", "path": "vpype_viewer/qtviewer/__init__.py"}]}