Open rudolphpienaar opened 1 year ago
Fold 4 user here. I have debian and xfce4 working just fine here. Let me run though my initial setup.
You must disable the background limit otherwise termux will crash eventually and it will be near impossible to run a proot distro at all let alone x11 apps.
At the time of writing I have Android 12 and One UI 4.1.1. You can disable this background process limit quite easily even without a dedicated computer to run android-tools on with a adb settings flag. More information about that can be found from here: https://github.com/agnostic-apollo/Android-Docs/blob/master/en/docs/apps/processes/phantom-cached-and-empty-processes.md#commands-to-disable-phantom-process-killing-and-tldr
The flag persists across reboots but you may need to undo the flag later for system updates by setting it back to true.
Would be to connect your device to a computer with android-tools installed, notably adb
. Enable developer settings on your device and then enable debugging in the developer options. Running the following adb command below.
adb shell settings put global settings_enable_monitor_phantom_procs false
But you can set the process limit flag from inside termux itself using adb wireless. Make sure you have only settings app and termux running, close everything else first.
In termux you will want to install 'android-tools' and 'fakeroot'
pkg install android-tools fakeroot
Then enable wireless debugging in developer menu, this is only Android 11+, you can get a pair code and everything. Settings > Developer Options > Wireless Debugging > Pair Code.
You have to tap next to the switch to get into the menu where it will allow you to pair with a code once the option is turned on.
Take note of the pair code and the port code it gives you in the menu, back in termux you'll need to run the following to connect first.
ANDROID_NO_USE_FWMARK_CLIENT=1 fakeroot adb pair localhost:<port> <pincode>
then after the pair go back and see the new port number to connect to
ANDROID_NO_USE_FWMARK_CLIENT=1 fakeroot adb connect localhost:<port>
Once connected you can then disable the flag with
ANDROID_NO_USE_FWMARK_CLIENT=1 fakeroot adb shell settings put global settings_enable_monitor_phantom_procs false
ANDROID_NO_USE_FWMARK_CLIENT=1 fakeroot
prefix is needed on Samsung devices, discused here: https://github.com/termux/termux-packages/issues/7946
OPTIONAL: you can clear a existing termux install by clearing the termux app data in android settings but backup what you want first.
pkg update
pkg upgrade
Extra note, be sure to install the included .deb file in the termux system, not under the proot.
pkg install ./path/to/.deb
You'll want to install the utility proot-distro, it makes this process so much easier.
pkg install proot-distro
I won't go into everything with proot-distro here but I did the following personally. This is just a idea of what to do, there maybe extra packages you want to install or even a different distro you might want to use. This is just literally what I did for my setup.
proot-distro install debian
proot-distro login debian
From inside the new proot shell
apt update
apt upgrade
apt install task-xfce-desktop
apt install dbus-launch
(xfce4 threw some errors without)
apt install sudo
usermod -m <new_user>
(-m flag to create a home directory for my user. EDITOR=nano visudo
(I like nano as a text editor and visudo to add my user to sudo so I can run some elevated processes, while proot isn't true root, not all apps will want to run as the "proot" root user)
exit
(leave the proot, you don't need to be in the proot to start it in the termux-x11 session)
Firstly you'll want to make sure allow-external-apps = true
is set in ~/.termux/termux.properties
outside the proot so that the termux-x11 companion app can access termux and processes. Only allow trusted apps after this point as any app can ask for permission to use your temux setup.
I find that you might have to force close the termux-x11 companion app before or after each session to get things to launch correctly.
I basically barrowed the script that @waldhef posted here https://github.com/termux/termux-x11/issues/138#issuecomment-1185572872
But I came across this for dbus, proot-distro login <some-distro> --bind /dev/null:/proc/sys/kernel/cap_last_cap
from here: https://gist.github.com/SaicharanKandukuri/20e66e816a8b2c3ea9d3f7657f09f807
If you want audio to work you need to install pulseaudio inside of termux
pkg install pulseaudio
My updated script that works for me is below
#!/data/data/com.termux/files/usr/bin/bash
# Enable PulseAudio over Network
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
# Prepare termux-x11 session
export XDG_RUNTIME_DIR=${TMPDIR}
termux-x11 :0 >/dev/null &
# Wait a bit until termux-x11 gets started.
sleep 3
# Login in PRoot Environment. Do some initialization for PulseAudio, /tmp directory
# and run xfce as your non-root user.
# See also: https://github.com/termux/proot-distro
# Argument -- acts as terminator of proot-distro login options processing.
# All arguments behind it would not be treated as options of PRoot Distro.
proot-distro login debian --shared-tmp --bind /dev/null:/proc/sys/kernel/cap_last_cap -- /bin/bash -c 'export PULSE_SERVER=127.0.0.1 && export XDG_RUNTIME_DIR=${TMPDIR} && su - <user> -c "env DISPLAY=:0 xfce4-session"'
exit 0
Save as whatever you'd like, I called my file start-xfce.sh. Swap out
Make sure to give the file inside termux executable permissions.
chmod +x start-xfce.sh
and then launch it.
./start-xfce.sh
As mentioned earlier, make sure termux-x11 companion app isn't running before running the script, it may fail if the termux-x11 app isn't running fresh.
When you are finished with a session and want to close out of everything. Log out in your desktop environment, force close the termux-x11 app, and type exit
in the termux shell. This will ensure everything is properly closed out and none of the termux or proot processes are taking up RAM or system resources.
Not related to termux-x11
So what did the author of this document ask us to do?
Closing as not worth keeping open. Discussions are welcome though. Thanks.
This is amazing @ShapeShifter499 ! I should update my original posting to reflect this perhaps, but your guide essentially made my whole day/month/year.
Some notes/comments? I can't seem to reliably get adb
shell access from within termux
. I can pair. Sometimes it connects. It never seems though to work beyond that . For setting the settings_enable_monitor_phantom_procs
I use the Play Store app, LADB
.
Another fun "struggle"... getting any DE other than xfce4
to work. Most of the usual suspects, GNOME
, KDE
, and derivativess complaing from the get go about dbus
issues. I have tried a couple of stabs-in-the-dark -- setting my UID within proot
to be the same as the host termux
(didn't help).
Have you had success with any DE other than xfce4
?
Some notes/comments? I can't seem to reliably get
adb
shell access from withintermux
. I can pair. Sometimes it connects. It never seems though to work beyond that . For setting thesettings_enable_monitor_phantom_procs
I use the Play Store app,LADB
.
I had not heard of LADB
so I'm glad that worked out for you.
Have you had success with any DE other than
xfce4
?
The only other desktop environment I've tried with so far was Gnome. I couldn't get it working and it is possible it might not work unmodified as it's starting to rely more and more on SystemD. SystemD unmodified can't run in proot as it wants to start as PID 1. I've seen some efforts online to get Gnome working without SystemD but I've not tried those yet.
But for the most part Gnome apps and others should work fine in XFCE as long as they don't rely on SystemD or dbus. For example I was using gThumb
and gscan2pdf
to help me compile documents I scanned or took photos of into pdf files earlier just fine.
A cool thing to note. If you have set up android file permissions for termux and run termux-setup-storage
, proot-distro
will by default bind the default android storage location to /sdcard
inside the proot session allowing the proot distro to read-write files to your normal android storage location. To add to that however, in my experience some applications could read files but not write for some reason. For example I couldn't write the compiled pdf with gscan2pdf
outside the proot but I could use thunar
to manually move the generated pdfs out of /home
to the /sdcard
directory and gThumb
was able to view and delete the photos I pointed it to. I'm not actually sure why that was but something to keep in mind if you experience any read-write issues to the simulated /sdcard
directory.
That auto bind feature for the storage can be disabled by passing --isolated
as mentioned at https://github.com/termux/proot-distro
Have the same issue with running XFCE on a Surface Go 2/BlissOS with Debian proot. Can also render Firefox in termux-x11 (with poor performance), but when running DISPLAY=:0 xfce4-session --display=:0
, termux-x11 is just a black screen and a cursor. There are no warnings and no errors, the command just hangs until SIGINT'ed.
Abstract
Running a Desktop Env (DE) from within a
termux
proot
intermux-x11
is desirable for many reasons. Aproot
will often be a more complete and "standard" Linux experience offering many more X11 applications than currently available in stocktermux
. Currently, however, this is problematic, as in my anecdotal experience I can't seem to run any DE from theproot
, with success only if thetermux
host runs the DE. While a closed older issue did address running a DE from aproot
, the solution no longer seems to be working.Introduction
I've been trying (and failing) to successfully and reliably run a desktop env (DE) from within a
proot-login
. The reasons forproot-login
DE ability are of course obvious -- aproot
, being a more "conventional" Linux installation, offers considerably more DE envs and X11 applications than the standardtermux
env which only seems to havexfce4
and very few X11 apps (nofirefox
/thunderbird
for example).Sources
There are several documented solutions (none of which work for me as of late November 2022). Most relevant is the closed issue #138 but there are others -- udroid and various postings on reddit of varying utility here, I thought to open an issue here as a central place to keep track.
Environment
My setup is a Samsung Galaxy Z Fold 3, hooked up to an external monitor that triggers DeX. By default, any attempt at running
termux-x11
or even somevnc
type solution will almost always die within a few minutes being killed by Android. A hack solution seems to be settingmax_phantom_processes
-- see here and a solution here.Previously proposed solution (not fully working for reasons unknown)
The core solution offered entails running/starting the
termux-x11
Xwayland
server intermux
, and then sharing the relevant UNIX domain socket that is created in thetermux
$XDG_RUNTIME_DIR
with theproot
environment. In this manner, X11 apps in theproot
can communicate with theXwayland
server instance.In summary, in
termux
:Now, enter the
proot
. Critically, note the--shared-tmp
flag -- this is the magic sauce that allows theproot
to share the sametmp
directory ($XDG_RUNTIME_DIR
) between the host andproot
):Obviously, in my above example, my
proot
is an Arch linux chroot. Now, in thisproot
, assuming I have installedxfce4
, the concept is to simply runxfce4-session
and it should connect to theXwayland
server running in the hosttermux
:(Note that some documentation erroneously indicates to run
env DISPLAY=:0 startxfce4
-- howeverstartxfce4
is a wrapper that tries to start an X server. Since an Xserver is already running in the host, this will result in anX server already running
error).Observed behaviour
I haven't been able to ever get the
xfce4
(or any other DE) started in theproot
to connect to the hostXwayland
. What has worked for me is to run/start the DE intermux
. Sincetermux
only seems to offerxfce4
this is the only environment possible:Now, in the
xfce4
DE, I can open aterminal
and within that terminal I canproot-distro login archlinux --shared-tmp
. At this point, I'm in a DE in thetermux
, but my terminal is now open onto theproot
. I can thenwhich runs the
firefox
from theproot
and displays on thetermux
Xwayland
.Oddities?
Any application in the
proot
that wants to communicate ondbus
seems to fail. Luckilyfirefox
doesn't usedbus
but many other modern apps do (sognome-terminal
won't work, butterminator
will). This limits the space of available applications considerably, but does hint at the fact thatdbus
communication might be the issue?I have tried many permutations, without success:
UID
in theproot
to be the sameUID
as in thetermux
host. Doesn't helpchmod 777 /tmp/dbus*
to see if I can speak todbus
from theproot
. Doesn't helpOther annoyances
termux-x11
"window" opens full screen (without the DeX window decoration), but the colors seem "washed out". I can close the window and reopen it, and the colors seem fine, but the annoying Dex top window bar returns.termux-x11
always seems to have a very annoying button bar at the bottom withEsc
, and what looks like cursor directions. I can't seem to get rid of this and it is very annoying.