2023-12-23 03:22:29 +00:00
|
|
|
#!/usr/bin/bash
|
2023-10-01 22:57:19 +00:00
|
|
|
|
|
|
|
source /etc/default/waydroid-launcher
|
|
|
|
|
2023-10-03 04:04:40 +00:00
|
|
|
# Kill any previous remnants
|
2023-10-01 22:57:19 +00:00
|
|
|
if [ "$(systemctl is-active waydroid-container.service)" == 'active' ]; then
|
2023-11-03 07:18:51 +00:00
|
|
|
pkexec /usr/libexec/waydroid-container-stop
|
2023-10-01 22:57:19 +00:00
|
|
|
fi
|
|
|
|
|
2023-11-01 20:40:01 +00:00
|
|
|
# Check if Waydroid is initialized, initialize if not
|
|
|
|
if grep -qz 'not initialized' <<< $(/usr/bin/waydroid status); then
|
|
|
|
/usr/bin/ujust init-waydroid
|
|
|
|
fi
|
|
|
|
|
2023-10-03 04:04:40 +00:00
|
|
|
# Launch Weston
|
2023-10-01 22:57:19 +00:00
|
|
|
killall -9 weston
|
2023-11-03 07:18:51 +00:00
|
|
|
pkexec /usr/libexec/waydroid-container-start
|
2023-10-01 22:57:19 +00:00
|
|
|
if [ -z "$(pgrep weston)" ]; then
|
2023-10-22 21:47:45 +00:00
|
|
|
/usr/bin/weston --socket=weston-waydroid --width=${WAYDROID_WIDTH:-1280} --height=${WAYDROID_HEIGHT:-800} &> /dev/null &
|
2023-10-01 22:57:19 +00:00
|
|
|
fi
|
|
|
|
|
2023-10-03 04:04:40 +00:00
|
|
|
# Launch Waydroid
|
2023-10-01 22:57:19 +00:00
|
|
|
sleep 2 &&
|
|
|
|
export XDG_SESSION_TYPE='wayland'
|
2023-10-02 18:04:21 +00:00
|
|
|
export WAYLAND_DISPLAY='weston-waydroid'
|
2023-11-01 20:40:01 +00:00
|
|
|
LAUNCH_PARAM=$@
|
|
|
|
/usr/bin/waydroid ${LAUNCH_PARAM:-first-launch} &
|
2023-10-03 04:04:40 +00:00
|
|
|
|
|
|
|
# Fix controllers, we know Waydroid has started because surfaceflinger is running
|
|
|
|
while [ "" == "$(pgrep surfaceflinger)" ]; do
|
|
|
|
sleep 1
|
|
|
|
done
|
2023-11-03 07:18:51 +00:00
|
|
|
pkexec /usr/libexec/waydroid-fix-controllers
|
2023-10-03 04:04:40 +00:00
|
|
|
|
|
|
|
# Waydroid is now live!
|
|
|
|
# Wait for exit and then clean up
|
|
|
|
while [ -n "$(pgrep weston)" ]; do
|
2023-10-01 22:57:19 +00:00
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
2023-11-03 07:18:51 +00:00
|
|
|
pkexec /usr/libexec/waydroid-container-stop
|