2
0

mjdev-session 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. # mjdev desktop wayland session
  3. # started by the display manager via /usr/share/wayland-sessions/mjdev.desktop
  4. export XDG_CURRENT_DESKTOP=mjdev
  5. export XDG_SESSION_TYPE=wayland
  6. export MOZ_ENABLE_WAYLAND=1
  7. export QT_QPA_PLATFORM="wayland;xcb"
  8. export _JAVA_AWT_WM_NONREPARENTING=1
  9. # allow wlroots to start on llvmpipe (software GL). On real hardware mesa uses the
  10. # GPU and this is ignored; in a VM / headless box without GPU passthrough mesa falls
  11. # back to llvmpipe and wlroots otherwise refuses to create a renderer ("Software
  12. # rendering detected, please use WLR_RENDERER_ALLOW_SOFTWARE") and the compositor
  13. # exits immediately -> black screen + tty1 autologin crash-loop.
  14. export WLR_RENDERER_ALLOW_SOFTWARE=1
  15. # the Compose shell renders via Skiko. On a software/llvmpipe stack (VM, or a box with
  16. # no GPU) the compositor's XWayland has no glamor, so Skiko cannot create an OpenGL/GLX
  17. # context -> "org.jetbrains.skiko.RenderException: Cannot create Linux GL context" and the
  18. # shell crash-loops. Skiko's CPU raster backend needs no GL context and works everywhere.
  19. # (On real GPUs this is the safe-but-slower path; revisit once GPU detection is added.)
  20. export SKIKO_RENDER_API=SOFTWARE
  21. # desktop shell binary - deb/appimage install location, gradle dev fallback
  22. SHELL_CMD="/opt/mjdev-desktop/bin/mjdev-desktop"
  23. if [ ! -x "$SHELL_CMD" ]; then
  24. SHELL_CMD="$HOME/.local/bin/mjdev-desktop"
  25. fi
  26. # compositor binary - /usr/bin (deb) or /usr/local/bin (manual install)
  27. MJDEVC="$(command -v mjdevc 2>/dev/null)"
  28. if [ -z "$MJDEVC" ]; then
  29. MJDEVC="/usr/bin/mjdevc"
  30. fi
  31. # clean up the activation environment the compositor exported into the
  32. # persistent systemd --user manager. with KillUserProcesses=no (the distro
  33. # default) that manager survives logout, so leaving a stale WAYLAND_DISPLAY /
  34. # DISPLAY behind poisons the next login - of any session, not just ours.
  35. # run on every exit path (normal exit, crash, signal) - no exec, so we get here.
  36. cleanup() {
  37. systemctl --user unset-environment \
  38. WAYLAND_DISPLAY DISPLAY XDG_CURRENT_DESKTOP XDG_SESSION_TYPE \
  39. 2>/dev/null || true
  40. }
  41. trap cleanup EXIT HUP INT TERM
  42. # log the compositor + shell output so a failed start is diagnosable (otherwise the
  43. # tty1 session just dies to a black screen with no trace). keep the previous run.
  44. LOG_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/mjdev-desktop"
  45. mkdir -p "$LOG_DIR"
  46. [ -f "$LOG_DIR/session.log" ] && mv -f "$LOG_DIR/session.log" "$LOG_DIR/session.log.1"
  47. "$MJDEVC" --session --shell-cmd "$SHELL_CMD" >"$LOG_DIR/session.log" 2>&1