Setting up Termux-X11 with Xfce4 for a Smooth Desktop Experience on Android
Transform your Android device into a lightweight desktop environment using Termux-X11 and Xfce4. This guide walks you through each step to ensure a clean and working setup.
Prerequisites
Make sure you have the latest versions of Termux and Termux-X11 installed from GitHub or F-Droid. If you’re unsure of your device’s architecture, download the universal build for compatibility.
Updating Repositories
Launch Termux and run:
termux-change-repo
Select the main repository and choose Grimler (or a newer option) for best performance. Then update all packages:
yes | pkg upgrade
Repository Selection
Run termux-change-repo again and choose a single mirror from the list for stable updates.
Configuration
Enable external app integration by editing your Termux properties file:
nano ~/.termux/termux.properties
Uncomment or add this line:
allow-external-apps = true
Save and reload settings:
termux-reload-settings
Alternatively, you can run a one-line command:
echo "allow-external-apps = true" >> ~/.termux/termux.properties && termux-reload-settings
Installing Dependencies
Subscribe to the X11 repository and install the required packages:
pkg install x11-repo && pkg install termux-x11-nightly xwayland -y
Installing Xfce4
Install the Xfce4 desktop environment:
pkg install xfce4 -y
Configuration for Termux-X11
Create a startup script to launch Termux-X11 with Xfce4:
echo 'termux-x11 :1 -xstartup "dbus-launch --exit-with-session xfce4-session"' > $PREFIX/bin/start-termux-x11 && chmod +x $PREFIX/bin/start-termux-x11
Starting Termux-X11
Start the Termux-X11 server:
start-termux-x11
Allow Termux to run in the background, then open the Termux-X11 app and wait for it to load.
Note: If dbus-launch fails, use this alternative command:
echo 'termux-x11 :1 -xstartup "xfce4-session"' > $PREFIX/bin/start-termux-x11 && chmod +x $PREFIX/bin/start-termux-x11
After running the script, use start-termux-x11 again. Keeping Termux-X11 open in Picture-in-Picture (PIP) mode helps maintain the session.
Proper Shutdown
To exit safely, log out from the Xfce4 desktop, then close the Termux-X11 app. Finally, log out from Termux before closing it.
Further Resources
Enjoy your new desktop environment powered by Termux-X11 and Xfce4. With the right setup, your Android device can function like a compact Linux workstation.