Aarron Lee 0b14aaefc6
fix(waydroid): waydroid-launcher script (#772)
Co-authored-by: Aarron Lee <aarron-lee@users.noreply.github.com>
2024-02-14 19:19:20 -08:00

35 lines
987 B
Bash
Executable File

#!/usr/bin/bash
source /etc/default/waydroid-launcher
# Kill any previous remnants
if [ "$(systemctl is-active waydroid-container.service)" == 'active' ]; then
pkexec /usr/libexec/waydroid-container-stop
fi
# Check if Waydroid is initialized, initialize if not
if grep -qz 'not initialized' <<< $(/usr/bin/waydroid status); then
/usr/bin/ujust init-waydroid
fi
# Launch Cage & Waydroid
pkexec /usr/libexec/waydroid-container-start
if [ -z "$(pgrep wlr-randr)" ]; then
cage -- bash -c "wlr-randr --output X11-1 --custom-mode ${WAYDROID_WIDTH:-1280}x${WAYDROID_HEIGHT:-800}; sleep 1; waydroid show-full-ui &> /dev/null &" &
fi
# Fix controllers, we know Waydroid has started because surfaceflinger is running
while [ "" == "$(pgrep surfaceflinger)" ]; do
sleep 1
done
sleep 10
pkexec /usr/libexec/waydroid-fix-controllers
# Waydroid is now live!
# Wait for exit and then clean up
while [ -n "$(pgrep cage)" ]; do
sleep 1
done
pkexec /usr/libexec/waydroid-container-stop