This article is only applicable only to Termux installations running on Android 7.0 or higher.
Termux provides support for programs that use X Window System. However, there no hardware acceleration for rendering and user will have to install a third party application to view graphical output.
To use X11-enabled programs, please, make sure that at least one of the following programs is installed:
VNC Viewer
The best choice for interacting with graphical environment. Requires
a running VNC server.
XServer XSDL
This one may be unstable but it provides a standalone Xorg server so
you don't have to setup VNC.
Termux:X11
A Termux add-on app that provides a Wayland compositor. Even if
though it's designed for Wayland, you can use Xwayland to run X11
applications.
X11 packages are available in a separate APT repository. You can enable it by running the following command:
$ pkg install x11-repo
It will automatically add appropriate sources.list file and PGP key.
To disable this repository, you need to uninstall package x11-repo
.
If you decided to use VNC for graphical output, follow these instructions for properly setting up VNC server.
tigervnc
:$ pkg install tigervnc
$ vncserver
At first time, you will be prompted for setting up passwords:
You will require a password to access your desktops.Password:Verify:Would you like to enter a view-only password (y/n)? n
Note that passwords are not visible when you are typing them and maximal password length is 8 characters.
New 'localhost:1 ()' desktop is localhost:1Creating default startup script /data/data/com.termux/files/home/.vnc/xstartupCreating default config /data/data/com.termux/files/home/.vnc/configStarting applications specified in /data/data/com.termux/files/home/.vnc/xstartupLog file is /data/data/com.termux/files/home/.vnc/localhost:1.log
It means that X (vnc) server is available on display 'localhost:1'.
$ export DISPLAY=":1"
You may even put this variable to your bashrc or profile so you don't have to always set it manually unless display address will be changed.
Here will be assumed that you use this Android VNC client: VNC Viewer (developed by RealVNC Limited).
Determine port number on which VNC server listens. It can be
calculated like this: 5900 + {display number}
. So for display
'localhost:1' the port will be 5901.
Now open the VNC Viewer application and create a new connection with the following information (assuming that VNC port is 5901):
If you are using VNC client on a computer using the same network as the phone does, make sure you correctly start a VNC session and know the IP address of the device.
Xserver setup is nearly same as for VNC. The only differences are that you don't have to configure authentication and variable "DISPLAY" should be set like
$ export DISPLAY=<the local IP address of your device>:0
Note that you don't need to set variable "PULSE_SERVER" like application suggests because Termux uses its own Pulseaudio package.
When using Android XServer rather than Android XSDL these are optional.
Simplest way to get a working graphical environment is to install i3:
$ pkg install i3 dmenu # dmenu is optional as you can use other application menu like rofi
It can be started automatically on VNC server startup. To do this, edit
file ~/.vnc/xstartup
as shown here:
#!/data/data/com.termux/files/usr/bin/sh# Start i3i3 &
It also has a easy and robust configuration, making it very popular amongst Linux ricers.
If you don't like tiling window managers, you can install Fluxbox:
$ pkg install fluxbox
Then, edit file ~/.vnc/xstartup
to look like this:
#!/data/data/com.termux/files/usr/bin/sh## Fluxbox desktop.# Generate menu.fluxbox-generate_menu# Start fluxbox.fluxbox &
Openbox requires a more complicated configuration than i3 and Fluxbox. Firstly you need to install some packages:
$ pkg install openbox pypanel xorg-xsetroot
Put the following lines to your ~/.vnc/xstartup
:
#!/data/data/com.termux/files/usr/bin/sh# Start Openbox.openbox-session &
Don't put anything else to file ~/.vnc/xstartup
but only lines shown
above since Openbox has own autostart script. It is located at
${PREFIX}/etc/xdg/openbox/autostart
(or alternatively at
~/.config/openbox/autostart
). Edit this file like here:
# Make background gray.xsetroot -solid gray# Launch PyPanel.pypanel &
It is possible to setup a full blown desktop environment in Termux. Only XFCE, LXQt and MATE is supported.
Recommended way of installation is through metapackage and not the separate components:
$ pkg install xfce4
VNC server startup configuration (~/.vnc/xstartup
) should contain only
#!/data/data/com.termux/files/usr/bin/shxfce4-session &
Additional recommended packages for installation:
otter-browser
xfce4-terminal
aterm
or st
.Recommended way of installation is through metapackage and not the separate components:
$ pkg install lxqt
VNC server startup configuration (~/.vnc/xstartup
) should contain only
#!/data/data/com.termux/files/usr/bin/shlxqt-session &
Additional recommended packages for installation:
otter-browser
qterminal
- Terminal emulator for LXQt. Included as a part of LXQtAs of now, there is no MATE metapackage as it's very unstable at the moment. So, you need to install all required MATE components serperately.
$ pkg install mate-* marco
VNC server startup configuration (~/.vnc/xstartup
) should contain only
#!/data/data/com.termux/files/usr/bin/shmate-session &
Additional recommended packages for installation:
otter-browser
mate-terminal
aterm
or st
.