6

I would like to make a script to start the Waydroid Android container (LineageOS).

Currently, I can start a LineageOS virtual phone without issues with:

sudo systemctl start waydroid-container
weston

And then, inside the weston-terminal:

waydroid session start
waydroid show-full-ui

Note that Waydroid only works in a Wayland session manager, and the Weston compositor is a simple way to run it with your ordinary X windows manager.

I do not know how should I insert the last two lines in the Bash launcher script. I tried to export

XDG_SESSION_TYPE=wayland  

but, while the Waydroid session starts, I am clueless on how to push the phone GUI to the Weston compositor.

There are of course X11 solutions, such as Anbox but Waydroid shines in comparison.

3 Answers 3

6

The variable to send Waydroid in place (i.e. inside Weston) is WAYLAND_DISPLAY not XDG_SESSION_TYPE. Also, the XWayland server should be activated.

So, make sure that the Waydroid container is on:

systemctl start waydroid-container

Now, you can launch your phone from your terminal/script with:

weston --xwayland &
export WAYLAND_DISPLAY=wayland-1              
sleep 2
waydroid show-full-ui &

Rather than kill Waydroid, a better way to close the phone:

waydroid session stop 

and Ctrl+Alt+Backspace to quit Weston.

For HiDPI diplay, you might add --scale 2 argument to Weston.

2

This is a script I found here reddit . Hope it helps. Also if it works for you let me know, Im in a similar position too.

#! /usr/bin/bash
if [ "$(systemctl is-active waydroid-container.service)" == 'active' ];then
    killall -9 weston
    sudo systemctl stop waydroid-container.service
    exit
fi
killall -9 weston
sudo systemctl restart waydroid-container.service
if [ -z "$(pgrep weston)" ]; then
    weston --xwayland &> /dev/null &
fi
sleep 2 &&
export XDG_SESSION_TYPE='wayland'
export DISPLAY=':1'
konsole --new-tab --hide-tabbar --hide-menubar -e '/usr/bin/waydroid show-full-ui' &
while [ -n "$(pgrep weston)" ];do
    sleep 1
done
sudo systemctl stop waydroid-container.service
2

This script works great for me, it starts weston and waydroid and when you close weston window it stops waydriod session automatically! Tested on Ubuntu and ArchLinux.

#!/bin/bash
export WAYLAND_DISPLAY=mysocket
weston --socket=$WAYLAND_DISPLAY --backend=x11-backend.so --width=1920 --height=1080 &
cmd1_pid=$!
waydroid show-full-ui &
wait $cmd1_pid
waydroid session stop
echo 'waydroid session stopped successfully!'
1
  • This should have been the accepted answer. Commented Jun 30, 2024 at 10:19

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.