Termux:X11
Downcodes Editor: Termux:X11 is a complete X server built using Android NDK and optimized for Termux. It allows you to run graphical applications in Termux.
about
Downcodes editor: Termux:X11 is a fully functional X server. It is built using Android NDK and optimized for Termux.
Notes on submodules
Downcodes Editor: This repository uses submodules. Please use the following command to clone the repository:
1. git clone --recurse-submodules https://github.com/termux/termux-x11
2. or
* git clone https://github.com/termux/termux-x11
* cd termux-x11
* git submodule update --init --recursive
Working principle
Downcodes editor: It works the same as other X servers.
Installation instructions
Downcodes editor: Termux:X11 requires Android 8 or higher. It contains an Android application and a companion Termux package, both of which you need to install.
1. Android application: Get the Android application from the nightly release tag of this repository. Download and install the app-$ARCHITECTURE-debug.apk file that matches your device's CPU architecture. If you are not sure which architecture to choose, you can choose app-universal-debug.apk, which will use additional storage space.
2. Matching Termux package: Obtain the matching Termux package from the Termux graphics warehouse. You can make sure it is enabled and install this package using pkg i x11-repo && pkg i termux-x11-nightly command. If needed, you can also download the .deb or *.tar.xz files from the nightly release tag mentioned above.
3. Desktop environment: Most users want to use a desktop environment on Termux:X11. If you don't know what this means or don't know which one to choose, run pkg i xfce (also from x11-repo) to install a good desktop environment as a starting point. The following instructions will assume that your goal is to run the XFCE desktop, or you can modify the instructions to suit your own goals.
Run graphics applications
Downcodes Editor: You can launch the desired graphics application using the following command:
1. termux-x11 :1 -xstartup "dbus-launch --exit-with-session xfce4-session"
2. or
*termux-x11:1&
* env DISPLAY=:1 dbus-launch --exit-with-session xfce4-session
If you are using a desktop environment other than XFCE, you can replace xfce4-session with the appropriate command.
For some users, dbus-launch does not work, you can use the following command to launch the session:
termux-x11 :1 -xstartup "xfce4-session"
You can also use the following command:
export TERMUXX11XSTARTUP="xfce4-session"
termux-x11 :1
In this case, you can save the TERMUXX11XSTARTUP variable to a .bashrc or other script so that you don't need to enter it manually each time termux-x11 is called.
Exit Termux:X11
Downcodes Editor: If you are done using Termux:X11, just exit via the notification drawer. Expand the Termux:X11 notification and click the "Exit" button.
However, please note that the termux-x11 command is still running and cannot be terminated this way.
Solve common problems
Downcodes editor: If you encounter the following problems, please try the following solutions:
1. Black screen: Some devices may display a black screen and cursor instead of normal output. In this case, pass the -legacy-drawing option:
termux-x11 :1 -legacy-drawing -xstartup "xfce4-session"
2. Color Swap: Some devices may display a color swap screen. In this case, pass the -force-bgra option:
termux-x11 :1 -force-bgra -xstartup "xfce4-session"
Used with the proot environment
Downcodes Editor: If you plan to use Termux:X11 with the proot environment, please note that you need to use the --shared-tmp option to start proot or proot-distro.
If you cannot pass this option, set the TMPDIR environment variable to point to the directory corresponding to /tmp in the target container.
If you are using proot-distro, you should know that you can start the termux-x11 command inside the proot container.
Used with chroot environment
Downcodes Editor: If you plan to use Termux:X11 with a chroot or unshare environment, you must run it as root and set the TMPDIR environment variable to point to the directory corresponding to /tmp in the target container.
This directory must be accessible from the shell from which termux-x11 is started, that is, it must be in the same SELinux context, the same mount namespace, etc.
You must also set the XKBCONFIGROOT environment variable to point to the container's /usr/share/X11/xkb directory, otherwise you will encounter xkbcomp related errors.
Force stop the X server
Downcodes Editor: The termux-x11 X server runs in a process named "app_process", not "termux-x11". You can end it by searching for "com.termux.x11" command.
You can end the X server with the following command:
pkill -f com.termux.x11
Close Android activity
Downcodes editor: You can use the following command to turn off Android activities:
am broadcast -a com.termux.x11.ACTION_STOP -p com.termux.x11
log
Downcodes Editor: If you need to obtain the logs of the com.termux.x11 application, please set the TERMUXX11DEBUG environment variable to 1, for example:
TERMUXX11DEBUG=1 termux-x11 :0
The logs obtained this way can be very long. It's best to redirect the command's output to a file immediately.
notify
Downcodes Editor: In Android 13, post notifications are restricted, so you need to explicitly allow Termux:X11 to display notifications.
Preferences
Downcodes Editor: You can access the preference menu in the following three ways:
1. Switch keyboards: Just press the "Back" button.
2. Touch gesture: Touchpad simulation mode.
In touchpad emulation mode, you can use the following gestures:
* Simulate touch screen mode
In simulated touch screen mode, you can use the following gestures:
3. Change, dump, and restore preferences from the command line
You can change termux-x11 preferences from the command line using the termux-x11-preference tool. termux-x11-nightly contains the termux-x11-preference tool, which can be used with the following command:
* termux-x11-preference [list] {key:value} [{key2:value2}]...
Use termux-x11-preference to dump current preferences.
Use termux-x11-preference > file to dump current preferences to a file.
Use termux-x11-preferences < file to restore preferences from a file.
Use termux-x11-preferences "fullscreen"="false" "showAdditionalKbd"="true" to disable fullscreen and enable the extra keybar. You can use the termux-x11-preference list command to view all preferences that can be modified. You can specify one or more preferences here.
* termux-x11-preference list
Lists all available preferences.
* termux-x11-preference "fullscreen"="false"
Change the "fullscreen" preference to "false".
* termux-x11-preference "showAdditionalKbd"="true"
Change the "showAdditionalKbd" preference to "true".
* termux-x11-preference > preferences.txt
Dumps the current preferences to a file named "preferences.txt".
* termux-x11-preference < preferences.txt
Restore preferences from a file named "preferences.txt".
* termux-x11-preference "fullscreen"="false" "showAdditionalKbd"="true" > preferences.txt
Change the "fullscreen" preference to "false" and the "showAdditionalKbd" preference to "true" and save the results to a file named "preferences.txt".
Termux:X11 activity should be available in the background or foreground, otherwise the termux-x11-preferences tool will hang indefinitely.
If the "Store preferences for secondary displays separately" preference exists, the termux-x11-preference tool will use or modify the preference of the display for which the Termux:X11 activity is currently open.
Use with third-party applications
Downcodes editor: You can use Termux:X11 to work with third-party applications.
Please see how shell-loader/src/main/java/com/termux/x11/Loader.java works.
license
Downcodes Editor: Released under the GPLv3 license.