Here is some information which may be useful in getting started, but I have not set this up for automatic run before…this is just to demo some of what needs to be done.
The script “/usr/bin/startx” can be used as a utility to start X on the command line (including shell scripts). Everything after the double dash “–” option is passed directly to the X program…or Xorg in this case. The pre-existing X which runs on a normal Ubuntu system starts with the ctrl-alt-F7 as its terminal, so this is virtual terminal 7 (VT7). This initial display is assigned the DISPLAY environment “:0”. To add an additional X session, using automatic selection of VT and DISPLAY, just run this (if “:0” is running on VT7 prior to this, then that is incremented and you will now also have “:1” on “VT8”):
startx --
With X already running as DISPLAY “:0” on VT7, this alternate command line creates a new session running as DISPLAY “:1” on VT5 instead of VT8, and gives verbose output as to what it is using for configuration:
startx -- vt5 -verbose
Note that some scripts check the kernel command line for the option “text” (which is why X startup scripts show kernel command line), and if this is found, X should not be run via scripts which check this. There are exceptions, and X itself does not check kernel command line for “text”. If you add this to the APPEND in extlinux.conf as a kernel option, then you’d boot only to text mode when using that boot entry (via serial console) and truly have no X run at all…useful for experimenting if you have serial console set up (this gets init involved in avoiding graphics…this goes beyond what having “text” in command line does):
APPEND ...stuff already there... systemd.unit=multi-user.target
If you boot with that, then there will be no graphical mode until you boot without “systemd.unit=multi-user.target”, or after manually running command “systemctl isolate graphical.target”. You could force the system back to text only via command “systemctl isolate multi-user.target”. The append option is just for boot time, interactive use of systemctl allows going back and forth between text and graphical run levels while experimenting. If you go to text mode via either booting with the systemd.unit=multi-user.target, or by manually running “systemctl isolate multi-user.target”, you can be sure that the only X you see is the one you manually start.
To forcibly start your session specifically as DISPLAY “:1” on VT5, even when “:0” does not exist:
startx -- :1 vt5
If you have qmlviewer installed, then from a text console or script, you can display it in that session via:
export DISPLAY=:1
qmlviewer &
So step one is to run X on the terminal you are interested in using a manually set/predictable DISPLAY environment variable. Then from anywhere else you can set DISPLAY to this and run an X application. X applications usually have options for “geometry”, and since there is no desktop window manager, you won’t be able to drag or resize applications with the mouse…you have to set this on command line. Conveniently, arguments passed to X after the “–” of startx include the ability to start X with particular resolution, e.g., 1920x1080…after which you can start your application with that geometry to do the equivalent of full screen. When you get that how you want, then add it to rc.local. If you need this to run as non-root, then you can use “sudo --user=someone ” for both the startx and the GUI app to run on that DISPLAY.
For a list of options you can pass to X, see “X -help 2>&1 | less”. If you run a normal X session without any intervention, see “ps a | grep Xorg” to see what the automatic session used for arguments. Note that startx is a convenience, Xorg can be called directly. I see this for a default automatic X startup:
728 tty7 ... /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
If you are in text mode, and run this sudo, you will get a completely unconfigured desktop responding as DISPLAY “:1” on VT5 (and you probably want unconfigured…startx still does some configuration even when not told to use a display manager, e.g., background color…this version has no background):
/usr/lib/xorg/Xorg -core :1 -seat seat0 -nolisten tcp vt5 -novtswitch
You’ll probably like this latter method of startup if you don’t mind running as root…I’m not sure what the setup requirement is to run without startx and still run as user ubuntu (or anyone other than root). Somewhere a simple sudo will do the trick, I just don’t know where that is without researching it.
Note that the “-nolisten tcp” is a security option to prevent remote networked interaction with your display. The “novtswitch” is explained in “X -help”, and may or may not be what you want.