7d96c20b28
Add P0-disable-qml-quick.patch for building KWin without QML/Quick dependencies. Update greeter scripts to prefer kwin_wayland. Enable kwin in redbear-full config. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
124 lines
3.7 KiB
Bash
Executable File
124 lines
3.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
export DISPLAY=""
|
|
export WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-0}"
|
|
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}"
|
|
|
|
if [ -z "${XDG_RUNTIME_DIR:-}" ]; then
|
|
export XDG_RUNTIME_DIR="/tmp/run/redbear-greeter"
|
|
fi
|
|
|
|
mkdir -p "$XDG_RUNTIME_DIR"
|
|
|
|
parse_drm_devices() {
|
|
local devices="${1:-}"
|
|
local part=""
|
|
|
|
IFS=':' read -r -a parts <<< "$devices"
|
|
for part in "${parts[@]}"; do
|
|
if [ -n "$part" ]; then
|
|
printf '%s\n' "$part"
|
|
fi
|
|
done
|
|
}
|
|
|
|
drm_devices_ready() {
|
|
local devices="${1:-}"
|
|
local device=""
|
|
|
|
for device in $(parse_drm_devices "$devices"); do
|
|
if [ ! -e "$device" ]; then
|
|
return 1
|
|
fi
|
|
done
|
|
|
|
return 0
|
|
}
|
|
|
|
wait_for_drm_devices() {
|
|
local devices="${1:-}"
|
|
local wait_seconds="${REDBEAR_DRM_WAIT_SECONDS:-2}"
|
|
local attempts=0
|
|
|
|
if [ -z "$devices" ]; then
|
|
return 1
|
|
fi
|
|
|
|
if [ "$wait_seconds" -le 0 ] 2>/dev/null; then
|
|
drm_devices_ready "$devices"
|
|
return $?
|
|
fi
|
|
|
|
attempts=$((wait_seconds * 2))
|
|
|
|
if ! drm_devices_ready "$devices"; then
|
|
echo "redbear-greeter-compositor: waiting up to ${wait_seconds}s for DRM device(s): ${devices}" >&2
|
|
fi
|
|
|
|
while [ "$attempts" -gt 0 ]; do
|
|
if drm_devices_ready "$devices"; then
|
|
return 0
|
|
fi
|
|
|
|
sleep 0.5
|
|
attempts=$((attempts - 1))
|
|
done
|
|
|
|
drm_devices_ready "$devices"
|
|
}
|
|
|
|
if [ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ] && command -v dbus-launch >/dev/null 2>&1; then
|
|
eval "$(dbus-launch --sh-syntax)"
|
|
fi
|
|
|
|
# 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 root first, then the selected card node.
|
|
if [ -n "${KWIN_DRM_DEVICES:-}" ]; then
|
|
desired_drm_devices="/scheme/drm:${KWIN_DRM_DEVICES}"
|
|
else
|
|
desired_drm_devices="/scheme/drm:/scheme/drm/card0"
|
|
fi
|
|
|
|
if wait_for_drm_devices "$desired_drm_devices"; 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
|
|
if [ "$COMPOSITOR" = "kwin_wayland" ] || [ "$COMPOSITOR" = "/usr/bin/kwin_wayland" ]; then
|
|
exec "$COMPOSITOR" --drm
|
|
else
|
|
exec "$COMPOSITOR" --drm
|
|
fi
|
|
else
|
|
unset KWIN_DRM_DEVICES
|
|
echo "redbear-greeter-compositor: DRM device not ready after wait, using virtual compositor backend" >&2
|
|
if [ "$COMPOSITOR" = "kwin_wayland" ] || [ "$COMPOSITOR" = "/usr/bin/kwin_wayland" ]; then
|
|
exec "$COMPOSITOR" --virtual
|
|
else
|
|
exec "$COMPOSITOR" --virtual
|
|
fi
|
|
fi
|