845ae99f9d
Three fixes for the KWin DRM device discovery failure: 1. drm_scheme_ready(): replace head -c 1 with exec 3< open test. Reading from a DRM scheme fd blocks because the scheme expects ioctl-style request/response, not streaming reads. Use open() success as the scheme availability probe instead. 2. ConsoleKitSession::create(): return nullptr immediately. The D-Bus isServiceRegistered() call can block indefinitely when the bus daemon doesn't fully implement org.freedesktop.DBus. With both LogindSession and ConsoleKitSession returning nullptr, Session::create() falls through to NoopSession which uses plain open() for DRM device access. 3. Boot chain deps: redox-drm depends on driver-manager, greeter depends on evdevd (keyboard/mouse ready before login). Also includes: KF6 CMake build fixes, Qt6 platform patches, libdrm Redox ioctl shim, and wayland.toml scheme check fix.
107 lines
4.2 KiB
Bash
Executable File
107 lines
4.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
# NOTE: Neither WAYLAND_DISPLAY nor DISPLAY may be exported when starting
|
|
# KWin. KWin uses their presence (even as empty strings) to select the
|
|
# nested Wayland or X11 backend instead of the bare-metal DRM/KMS backend.
|
|
# Clients (the greeter UI, KDE session apps) receive WAYLAND_DISPLAY from
|
|
# redbear-session-launch instead.
|
|
unset DISPLAY
|
|
unset WAYLAND_DISPLAY
|
|
export XDG_SESSION_TYPE=wayland
|
|
export LIBSEAT_BACKEND=seatd
|
|
export SEATD_SOCK=/run/seatd.sock
|
|
export QT_PLUGIN_PATH="${QT_PLUGIN_PATH:-/usr/plugins}"
|
|
export QT_QPA_PLATFORM_PLUGIN_PATH="${QT_QPA_PLATFORM_PLUGIN_PATH:-/usr/plugins/platforms}"
|
|
export QML2_IMPORT_PATH="${QML2_IMPORT_PATH:-/usr/qml}"
|
|
export QT_WAYLAND_SHELL_INTEGRATION="${QT_WAYLAND_SHELL_INTEGRATION:-xdg-shell}"
|
|
export XCURSOR_THEME="${XCURSOR_THEME:-Pop}"
|
|
export XKB_CONFIG_ROOT="${XKB_CONFIG_ROOT:-/usr/share/X11/xkb}"
|
|
export KWIN_COMPOSE="${KWIN_COMPOSE:-O2}"
|
|
export QT_DEBUG_PLUGINS=1
|
|
export QT_LOGGING_RULES="${QT_LOGGING_RULES:-*.debug=true}"
|
|
export MESA_LOADER_DRIVER_OVERRIDE="${MESA_LOADER_DRIVER_OVERRIDE:-virtio_gpu}"
|
|
|
|
if [ -z "${XDG_RUNTIME_DIR:-}" ]; then
|
|
export XDG_RUNTIME_DIR="/tmp/run/redbear-greeter"
|
|
fi
|
|
|
|
mkdir -p "$XDG_RUNTIME_DIR"
|
|
|
|
drm_scheme_ready() {
|
|
# Check if /scheme/drm/card0 can be opened. On Redox, stat and test -e
|
|
# are unreliable for scheme paths. Opening the scheme path with redir
|
|
# succeeds if the scheme daemon has registered the device, fails otherwise.
|
|
# Do NOT read from it (head -c 1) — DRM scheme fds are request/response,
|
|
# not streaming, so a read would block waiting for a request response.
|
|
( exec 3<"/scheme/drm/card0" && exec 3>&- ) >/dev/null 2>&1
|
|
}
|
|
|
|
wait_for_drm_scheme() {
|
|
local wait_seconds="${REDBEAR_DRM_WAIT_SECONDS:-10}"
|
|
local attempts=0
|
|
|
|
if drm_scheme_ready; then
|
|
return 0
|
|
fi
|
|
|
|
echo "redbear-greeter-compositor: waiting up to ${wait_seconds}s for DRM device(s): /scheme/drm:/scheme/drm/card0" >&2
|
|
|
|
attempts=$((wait_seconds * 2))
|
|
|
|
while [ "$attempts" -gt 0 ]; do
|
|
if drm_scheme_ready; then
|
|
return 0
|
|
fi
|
|
|
|
sleep 0.5
|
|
attempts=$((attempts - 1))
|
|
done
|
|
|
|
drm_scheme_ready
|
|
}
|
|
|
|
# Prefer kwin_wayland (real KWin compositor). Fall back to redbear-compositor only if
|
|
# KWin is not installed (e.g. text-only target accidentally includes greeter).
|
|
COMPOSITOR=""
|
|
if command -v kwin_wayland >/dev/null 2>&1; then
|
|
COMPOSITOR="kwin_wayland"
|
|
elif command -v /usr/bin/kwin_wayland >/dev/null 2>&1; then
|
|
COMPOSITOR="/usr/bin/kwin_wayland"
|
|
elif command -v redbear-compositor >/dev/null 2>&1; then
|
|
COMPOSITOR="redbear-compositor"
|
|
echo "redbear-greeter-compositor: kwin_wayland not found, falling back to redbear-compositor" >&2
|
|
else
|
|
echo "redbear-greeter-compositor: no compositor found (need kwin_wayland or redbear-compositor)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# pcid-spawner is intentionally async in Red Bear OS, so service ordering only guarantees that
|
|
# spawning has started. Wait for the DRM scheme to appear.
|
|
if wait_for_drm_scheme; then
|
|
export KWIN_DRM_DEVICES="${KWIN_DRM_DEVICES:-/scheme/drm/card0}"
|
|
echo "redbear-greeter-compositor: using DRM compositor backend (KWIN_DRM_DEVICES=${KWIN_DRM_DEVICES})" >&2
|
|
|
|
# NOTE: QDBusConnection::sessionBus() blocks on Redox when attempting Unix socket
|
|
# connect(), even when dbus-daemon is running. All KWin sessionBus() calls in the
|
|
# startup path have been bypassed in the KWin source. We do NOT set
|
|
# DBUS_SESSION_BUS_ADDRESS so that remaining sessionBus() calls with env-var guards
|
|
# skip gracefully. If a future change re-enables D-Bus session bus, the Qt/Redox
|
|
# Unix socket connect() issue must be resolved first.
|
|
|
|
echo "redbear-greeter-compositor: env DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS:-unset} DBUS_SYSTEM_BUS_ADDRESS=${DBUS_SYSTEM_BUS_ADDRESS:-unset}" >&2
|
|
echo "redbear-greeter-compositor: launching $COMPOSITOR" >&2
|
|
unset QT_QPA_PLATFORM
|
|
"$COMPOSITOR"
|
|
EXIT_CODE=$?
|
|
echo "redbear-greeter-compositor: compositor exited with code $EXIT_CODE" >&2
|
|
exit $EXIT_CODE
|
|
fi
|
|
|
|
# No DRM at all — fall back to virtual backend.
|
|
unset KWIN_DRM_DEVICES
|
|
echo "redbear-greeter-compositor: no DRM device found, using virtual compositor backend" >&2
|
|
"$COMPOSITOR"
|
|
exit $?
|