Launching programs with GUI without display manager

Solution 1:

You can run them with no display manager, but you do need a running X session. The details will depend on your distribution but you should be able to get a minimal X session with a single terminal by running

xinit

I haven't done this in years but, last time I did, that would give something like this:

enter image description here

Once there, you can run a GUI program normally, preferably by launching it in the background (with &) so you don't loose access to your only terminal.

Solution 2:

Here is the basics for running an GUI app headless, with a way (vnc) to connect to it. Works on RHEL7 and Centos 7, with family. And ripped out of my own Docker-image that I use for Crashplan located at https://github.com/xeor/dockerfiles/tree/master/crashplan/ (see Dockerfile for setup, and init/setup for startup.

# Needed environment variables
export DISPLAY=:99.0
export SCREEN_WIDTH=1200
export SCREEN_HEIGHT=960
export SCREEN_DEPTH=24
export GEOMETRY="${SCREEN_WIDTH}x${SCREEN_HEIGHT}x${SCREEN_DEPTH}"

# Needed packages
yum install -y xorg-x11-server-Xvfb x11vnc gtk2 xorg-x11-fonts-*

# Set a password (if variable vncpass is sat, else its `secret`)
mkdir -p ~/.vnc && x11vnc -storepasswd ${vncpass:-secret} ~/.vnc/passwd

# Start up the fake display and run the application you want (the `java ...` part)
xvfb-run --server-args="$DISPLAY -screen 0 $GEOMETRY -ac +extension RANDR" java .... > log/ui_output.log 2> log/ui_error.log &

# Wait for the app to start, or else, the vnc server will die before starting
sleep 5

# vnc itself
x11vnc -forever -usepw -shared -rfbport 5900 -display $DISPLAY

You should now be able to connect to the server:5900 and see the application.

Solution 3:

Yes. Just do the same things a display manager does. Aside from the graphical login screen (which you don't need in this case), the display manager just does two things:

  1. First it starts an X11 "display server", such as Xorg,
  2. then starts "clients" which tell Xorg what & where to draw.

You can use tools like startx to start X11 the same way from a console login; it will launch Xorg followed by the clients listed in your ~/.xinitrc file.

For example, the .xinitrc file could have startkde or gnome-session, or it could list the individual components (the window manager, a panel/taskbar, a desktop...)

(Note that there are some differences between xinit and startx – usually you should use the latter, since some distros have a few important pieces of configuration that plain xinit will ignore, namely the xserverrc script.)

With Wayland, the desktop & panels are an integrated part of the "compositor", so the entire interface starts in a single step without additional tools. For example, you can run weston or start GNOME using gnome-session --session=gnome-wayland.