How to use Termux X11 - The X server on Android phone

🇹🇼 中文版

Termux X11 is a Termux add-on app providing Android frontend for X. The performance is better than VNC server. Although it supports touching gestures, it’s better to have your mouse and keyboard connected to the phone.

1. Install Termux X11

Termux X11 is still in alpha stage.

  1. Install Termux

  2. Login to your Github account. Download latest APK from Termux-x11 Github workflows. Download the Termux X11 APK (Branch: master)

  3. Unzip the archives and install Termux-x11 apk.

  4. Launch Termux, instal x11-repo. Then install termux-x11-nightly

1
2
3
pkg update
pkg install x11-repo
pkg install termux-x11-nightly

2. Run X11 apps in Termux

  1. Open Termux X11 APP and you will see this

  2. Go back to Termux. Install XFCE4 and GIMP

1
pkg install xfce gimp
  1. Launch XFCE4 with dbus-launch
1
termux-x11 :0 -xstartup "dbus-launch --exit-with-session xfce4-session"

If you encounter Make sure an X server isn't already running(EE) error, close Termux, then “Force stop” and “Clear cache” Termux and Termux X11 in Android system settings.

  1. Now you should see XFCE4 runnning in Termux X11.

  2. You could change Touchscreen input mode in Termux X11 preferences in notification bar.

  3. If the font is too big, open System settings → Appearance → check Cutsom DPI。

  4. Press CTRL+Z in Termux to stop XFCE4.

3. Run X11 apps in Proot-distro

  1. Install a proot-distro. For example Debian or Arch Linux.

  2. Open Termux X11 app. Then go back to Termux.

  3. Login to proot-distro as a normal user with --shared-tmp.

1
proot-distro login --user user debain --shared-tmp
  1. Add user to video and audio groups:
1
sudo usermod -aG video,audio $USER
  1. Launch desktop environment. For example, XFCE4
1
termux-x11 :0 -xstartup "dbus-launch --exit-with-session xfce4-session"
  1. Install onboard package for the floating keyboard.

  2. Proot-distro have more packages than Termux. For an instance, it is possible to play Minecraft with MultiMC.

4. Run X11 apps in chroot

Root permission is required.

  1. Setup a chroot environment, for exmaple chroot Ubuntu with XFCE4

  2. Set SELinux to Permissive

1
sudo setenforce 0
  1. Start Termux X11 APP. Go back to Termux, execute:
1
termux-x11 :0 -ac &
  1. Log into chroot. Start XFCE4
1
2
3
chmod -R 777 /tmp
export DISPLAY=:0 PULSE_SERVER=tcp:127.0.0.1:4713
dbus-launch --exit-with-session startxfce4 &

5. Starting Wayland session in Termux

Termux-x11 is a XWayland server. However it is possible to start a nested Wayland session.

Just intall weston and launch it in the terminal:

1
weston

6. GPU Acceleration in Termux X11

See:virglrenderer: Termux GPU Hardware Acceleration Tutorial


Thanks for your reading. You are welcome to share articles of Ivon's Blog (ivonblog.com). Please include the original URL when reprinting or citing articles, and abide by CC BY-NC-ND 4.0 license. For commercial use, please write an e-mail to me.

written by human, not by AI

If this article is helpful to you please consider supporting me.

Leave a comment

Choose the commenting system you like.

Please login to your Github account to leave a comment. You can post codes here for discussion. For images, please upload to Imgur and copy links. Your comments would be visible to everyone on Github Discussions.

This comment system is provided by Disqus, you may see some Disqus ADs on this page. You can leave a comment anonymously but you won't receive reply notifications.