#!/usr/bin/bash set -eux # Import defaults if WIDTH/HEIGHT is not defined by an external script if [ -z "${WAYDROID_WIDTH:-}" ] || [ -z "${WAYDROID_HEIGHT:-}" ]; then source /etc/default/waydroid-launcher fi # for backwards compatibility, default to show-full-ui if (($# == 0)); then set -- show-full-ui fi # 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, send user to the docs if grep -qz 'not initialized' <<< $(/usr/bin/waydroid status); then xdg-open "https://docs.bazzite.gg/Installing_and_Managing_Software/Waydroid_Setup_Guide/" exit 1 fi launch_waydroid() { wlr-randr --output X11-1 --custom-mode "$1" sleep 1 shift exec waydroid "$@" &> /dev/null } export -f launch_waydroid # Launch Cage & Waydroid pkexec /usr/libexec/waydroid-container-start if [ -z "$(pgrep wlr-randr)" ]; then cage -- bash -uxc 'launch_waydroid "$@"' _ "${WAYDROID_WIDTH:-1280}x${WAYDROID_HEIGHT:-800}" "$@" & 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