1 Background

Termux’s x11-repo support running xorg server and xfce on android directly, but it is not a normal GNU/Linux environment and lacks some usual graphical applications, which limit its usage under many circumstances. Luckily, people can workaround this by running a fake GNU/Linux system with proot technology provided by termux, and a xfce environment live in proot is supported as well.

2 What proot can do

I can use libreoffice, openconnect (a VPN client likes Cisco’s anyconnect), firefox in proot environment and it works well.

3 General steps

  1. Install proot proot-distro in termux

  2. Install latest debian stable version by proot-distro install debian

  3. Login into debian proot environment by proot-distro login debian and:

    • install xfce and related packages: apt-get install dialog xfce4 xfce4-goodies
    • install tigervnc server: apt-get install tigervnc-standalone-server dbus-x11 , note generally you still need to install dbus-x11, otherwise strange problem might happen during vnc server running
    • (Optional) install some common packages: apt-get install dialog apt-utils less netcat-openbsd openssh-client
  4. Setup tigervnc server in proot environment, edit file ~/.vnc/Xtigervnc-session, and write below lines in it:

    xfce4-session
    # or
    # dbus-launch --exit-with-session xfce4-session
    

    run tigervncpasswd to set vnc password

    edit ~/.vnc/tigervnc.conf and write below lines in it:

    $rfbport = "5900";
    $geometry = "1280x720";
    $depth = "32";
    $localhost = "no";
    $SecurityTypes = "TLSVnc";
    $UseBlacklist = "yes";
    $BlacklistThreshold = "2";
    $BlacklistTimeout = "86400";
    $IdleTimeout = "0";
    $QueryConnect = "no";
    $AcceptSetDesktopSize = "yes";
    $PasswordFile = "/root/.vnc/passwd";
    $AlwaysShared = "yes";
    
  5. Exit from debian proot session, and execute proot-distro login debian -- tigervncserver :1 -fg to run vnc server in foreground

4 Daemonize

It is possible to make vnc server running in proot environment as a daemon by termux-service, consider steps below:

  1. Create a new sv directory according to its wiki, for example: you can use debian-vnc as service name

  2. Create a file named run at it, content (we assume running vnc server at display :2):

    exec proot-distro login debian -- bash -c 'rm /tmp/.X11-unix/X2 ; rm /tmp/.X11-lock/X2 ; rm /tmp/.X2-lock ; tigervncserver :2 -fg' 2>&1
    
  3. Then you can launch service by sv up debian-vnc

5 Using termux-x11

Termux-x11 is worth when your mobile device screen is large enough (for example you have a tablet), otherwise I think it is useless.

6 Troubleshooting

  • Disable settings_enable_monitor_phantom_procs on android when you get [Process completed (signal 9) - press Enter] error
  • Remove power management plugin from xfce panel if xfce consume too many memory and cause OOM of android
  • Go back to termux and install packages from proot-distro login if you face apt error unable to open '/usr/share/applications/htop.desktop.dpkg-new': Permission denied

7 Limitation

  • It is seems that impossible to launch vnc server in debian correctly by termux-service, because sv command can not manage processes which running at background vnc server process can run at foreground and be managed by termux-service