dnschneid / crouton

Chromium OS Universal Chroot Environment
https://goo.gl/fd3zc?si=1
BSD 3-Clause "New" or "Revised" License
8.57k stars 1.24k forks source link

Install X11 display without a desktop #4103

Closed ghost closed 5 years ago

ghost commented 5 years ago
name: buster
encrypted: no
Entering /mnt/stateful_partition/crouton/chroots/buster...
crouton: version 1-20190710132432~master:7e345389
release: buster
architecture: amd64
targets: cli-extra
host: version 12105.90.0 (Official Build) stable-channel setzer 
kernel: Linux localhost 3.18.0-19346-g9ff80f5e4c97 #1 SMP PREEMPT Thu Jul 4 00:32:47 PDT 2019 x86_64 GNU/Linux
freon: yes
Not unmounting /mnt/stateful_partition/crouton/chroots/buster as another instance is using it

Please describe your issue:

Trying to run a Java Swing app using cli-extras. Is it possible to install an X11 Display manager without a desktop? I can run Java Swing in Crostini.

If known, describe the steps to reproduce the issue:

Try to run a Java Swing app using Debain buster cli-extras with OpenJDK 11

No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:208)
DennisLfromGA commented 5 years ago

@aidylewis,

It looks like the cli-extra target only requires the core target and no x11 stuff is installed.

Is it possible to install an X11 Display manager without a desktop?

x11
        X11 via autodetected backend. Does not install any desktop environment.

Yes, you could update your chroot adding the x11 target like this:

That should satisfy the x11 requirement and hopefully the Java Swing app requirements.

Hope this helps, -DennisLfromGA

ghost commented 5 years ago

Thanks for the response @DennisLfromGA and the -u flag which didn't delete my config. Will I need to manually start the x11 server - it doesn't seem to be running?

$ ~ xset q
xset:  unable to open display ""
DennisLfromGA commented 5 years ago

@aidylewis,

You may have to set the display first, try -

export DISPLAY=:0
xset q

I tried that when just using enter-chroot and it did not work for me.

If the 'xiwi' xmethod was installed when you did your update you may be able to use it with your java app using something like:

See below for startxiwi usage:

startxiwi [options] chroot_app [parameters]

Wraps enter-chroot to launch a window or tab in Chromium OS for any graphical application.
Applications launched in this way show in independent windows or tabs.

By default, it will use the primary user on the first xiwi-enabled chroot found and launch
the chroot_app in a window.

Options:
    -b          Fork and run the specified command silently in the background.
    -c CHROOTS  Directory the chroots are in. Default: /mnt/stateful_partition/crouton/chroots
    -k KEYFILE  Override the auto-detected encryption key location.
    -n NAME     Name of the chroot to enter. Default: first one found in CHROOTS
    -t TARGET   Only enter the chroot if it contains the specified TARGET.
    -u USERNAME Username (or UID) to log into. Default: 1000 (the primary user)
    -F          Launch the chroot_app full-screen.
    -T          Launch the chroot_app in a tab.
    -f          Prevent xiwi from quitting automatically. (see NOTE below)

NOTE:
xiwi will normally close when the application returns. Some gui applications
fork before or during normal operation, which can confuse xiwi and cause it to
quit prematurely. If your application does not have a parameter that prevents
it from forking, and crouton is unable to automatically detect the fork, you can
use -f to prevent xiwi from quitting automatically.
xiwi will quit if you close the Chromium OS window when nothing is displayed.

You can cycle through multiple windows inside the application
via Ctrl-Alt-Tab/Ctrl-Alt-Shift-Tab, or close them via Ctrl-Alt-Shift-Escape.
If the chroot_app begins with 'start' but you still want to
use the default window manager, specify the full path of the application.

When you added the x11 target it should have also installed the 'xorg' or 'xiwi' xmethod which installs many X11 packages. When you did the update to add x11 you may have seen something like this when it completed:

With xorg:

You can flip through your running chroot desktops and Chromium OS by hitting Ctrl+Alt+Shift+Back and Ctrl+Alt+Shift+Forward.

With xiwi:

You can open your running chroot desktops by clicking on the extension icon. Once in a crouton window, press fullscreen or the "switch window" key to switch back to Chromium OS. You can launch individual apps in crouton windows by using the "xiwi" command in the chroot shell. Use startxiwi to launch directly from the host shell. Use the startxiwi parameter -b to run in the background. Example: sudo startxiwi -b xterm

You can add them manually with an update like:


Hope this helps, -DennisLfromGA

ghost commented 5 years ago

Thanks @DennisLfromGA

sudo crouton -n buster -t xiwi -u
sudo startxiwi -n buster -f google-chrome

Is there a way to financially contribute to this project on a rolling basis? I am using a £150 Chromebook for home and work development - which is quite incredible.

ghost commented 5 years ago

Is it possible to return back to the terminal and use for example google-chrome?

DennisLfromGA commented 5 years ago

@aidylewis,

If you mean returning to your terminal session and not tying it up the yes, use the '-b' option to run it in the background like:

If you mean return to the Chrome OS screen from the xiwi window then yes, you can use the key-combos ctrl+alt+shift+F1/Back and ctrl+alt+shift+F2/Forward to switch back and forth. From Chrome OS just use the same key-combo or the crouton integration extension in the browser toolbar and select your chroot, see below -

Screenshot 2019-09-08 at 5 37 16 PM

There are other ways to launch your xiwi session too, like:

EDIT: You can now use the new virtual desks feature and switch between them with shift+launcher+] and shift+launcher+[. See below for my three virtual desks with: browser, hangouts, crouton-xiwi -

crouton-xiwi-virtual-desks

Hope this helps, -DennisLfromGA

TheTechRobo commented 2 years ago
name: bullseye
encrypted: yes, unlocked
Entering /mnt/stateful_partition/crouton/chroots/bullseye...
crouton: version 1-20210907212903~master:9b281df5
release: bullseye
architecture: amd64
xmethod: xorg
targets: x11,xiwi,xorg,cli-extra,extension
host: version 14150.87.0 (Official Build) stable-channel grunt 
kernel: Linux localhost 4.14.243-18084-g7bc10658733d #1 SMP PREEMPT Tue Nov 9 13:59:04 PST 2021 x86_64 GNU/Linux
freon: yes
➜  ~ xset q                    
xset:  unable to open display ""
➜  ~ export DISPLAY=:0
➜  ~ xset q           
xset:  unable to open display ":0"
➜  ~ export DISPLAY=127.0.0.1:0
➜  ~ xset q                    
xset:  unable to open display "127.0.0.1:0"
➜  ~ export DISPLAY=127.0.0.1:1
➜  ~ xset q                    
xset:  unable to open display "127.0.0.1:1"
➜  ~ export DISPLAY=192.168.2.1:0
➜  ~ xset q                      
xset:  unable to open display "192.168.2.1:0"
➜  ~ 

Debian Bullseye chroot.