Make sure your device is rooted, and your kernel supports switching SELinux to Permissive. If not, trying to set SELinux to Permissive will cause a system-wide crash.
termux-setup-storage
echo "allow-external-apps = true" >> .termux/termux.properties
apt update
apt full-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
pkg install root-repo x11-repo -y
pkg install neofetch wget openssh pulseaudio tsu -y
wget https://github.com/iamSlightlyWind/termux-x11/raw/master/termux-x11.deb
dpkg -i termux-x11.deb
apt install -f -y
Using: LinuxDeploy
Distro: Debian Stable
Arch: Armhf
SSH: Enable
PulseAudio: Enable
Init: Enable
Init settings/Init path: /home/your_username/startup #Will create startup file later in step Configure chroot
#Install dependencies
sudo apt-get install aria2 git curl wget nano build-essential cmake zip unzip python3 -y
#Update debian
sudo apt-get update
sudo apt-get full-upgrade -y
#Fish shell (optional)
echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_11/ /' | sudo tee /etc/apt/sources.list.d/shells:fish:release:3.list
curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:3/Debian_11/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/shells_fish_release_3.gpg > /dev/null
sudo apt-get update
sudo apt-get install fish -y
#Compile Mesa
sudo apt-get install autoconf libxcb-shm0-dev pkg-config python3-pip libxcb-shm0-dev make cmake meson ninja-build libjpeg-dev libpng-dev -y
sudo apt-get build-dep mesa -y
aria2c -x4 https://github.com/Grima04/mesa-turnip-kgsl/archive/refs/heads/main.zip
unzip mesa-turnip-kgsl-main.zip
cd mesa-turnip-kgsl-main
meson build -D platforms=x11,wayland -D gallium-drivers=swrast,virgl,zink -D vulkan-drivers=freedreno -D dri3=enabled -D egl=enabled -D gles2=enabled -D glvnd=true -D glx=dri -D libunwind=disabled -D osmesa=true -D shared-glapi=enabled -D microsoft-clc=disabled -D valgrind=disabled --prefix /usr -D gles1=disabled -D freedreno-kgsl=true
cd build
sudo ninja install
#Setup Xwayland
sudo mkdir /termx11
sudo chmod 777 /termx11
sudo chmod 777 /etc/environment
echo "DISPLAY=:0" >> /etc/environment
echo "XDG_RUNTIME_DIR=/termx11" >> /etc/environment
sudo apt-get install weston xwayland dbus-x11 i3 -y
#Compile box86
cd ~
git clone https://github.com/ptitSeb/box86
cd box86
mkdir build; cd build; cmake .. -DARM_DYNAREC=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo; make -j$(nproc --all)
sudo make install
#Remove Xwayland redundancy at boot
echo "rm -rf /termx11/*" >> ~/startup
chmod 777 ~/startup
#Audio
sudo apt-get install pulseaudio -y
echo "PULSE_SERVER=127.0.0.1" >> /etc/environment
mkdir wine_binary
cd wine_binary
aria2c -x4 https://www.playonlinux.com/wine/binaries/phoenicis/upstream-linux-x86/PlayOnLinux-wine-7.4-upstream-linux-x86.tar.gz
tar xf *.gz
Note: I haven't found an easy way to move and merge folders, granted I only looked at the first google page. To avoid all the hassle just use a root file manager, move and merge it yourself. Using LinuxDeploy, the chroot filesystem is mounted at /data/local/mnt
of Android's filesystem. You should move the extracted files to /usr/local/
within the chroot. Some shell requires you to log out (of SSH in this situation) and log in again for it to see changes in /usr/local/
. I have tried moving the files by installing a file manager in the chroot and running it as root, but Xauth is preventing me, and it's not a problem worth dealing with. Alternatively just add read/write permission for your user at /usr/local/
and copy there using your favorite file manager (eg nautilus, dolphin, etc)
This pre-built Termux-x11 has it's XDG_RUNTIME_DIR
set to /data/local/mnt/termx11/
, same as step Setup Xwayland in Configure chroot. With this, you won't need to symlink the socket as described here.
Termux-x11 will only work if you already started the chroot container. If not, check the notification to stop the service, and if Termux has any running tasks you will need to stop them too.
Whenever you start a chroot container and intend to use Termux-x11. Make sure that:
- SELinux is set to permissive, using Termux:
su -c setenforce 0
And then start Termux-x11. On my device, Termux-x11 doesn't show "Service was created" every time after a chroot container was mounted. So you must check the /termx11/
path of the chroot to see if the 2 socket files were created. If they are already there before Termux-x11 was started, It is advisable to remove them first with rm -rf /termx11/*
, though it should already be removed when starting a container from LinuxDeploy using the init script at /home/your_username/startup
. Stop Termux-x11 from the notification bar and start it again. Socket files should now be created in chroot's /termx11/
.
Alternatively, start your chroot container and start Termux-x11; if the "Service was created" notification did not pop up, open the notification bar and stop Termux-x11; when starting it again, the notification "Service was created" should pop up. If not, check it manually as described above.
- Listen to chroot audio, using Termux:
pulseaudio --start --exit-idle-time=-1
pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1
Once SSH into the chroot, you can run the following command to start a shell on the Xwayland session:
Xwayland :0 -noreset & sleep 1 && fish #or any shell of your choice
If Xwayland returns "Couldn't add screen", try the debugging steps above.
After that, start a windows manager to make use of Termux-x11 auto-resizing feature:
i3 &
Configure wine:
box86 wine winecfg
And start the program/game you wanted using wine:
box86 wine app.exe
- Note:
export GALLIUM_DRIVER=zink
for better 3D performance since Mesa is already compiled. But if you encounter problems while using Zink, switch back to the default renderer withexport GALLIUM_DRIVER=llvmpipe
. Example:GALLIUM_DRIVER=zink box86 wine game.exe