Here is a similar reply to a recent question:
Basic flow of boot is:
At graphical stage: getty/agetty -> replaces one console login with X11 using login manager arguments
At graphical login: login manager -> replaces existing X+login with X+window manager run sudo user
- kernel load -> starts init
- [u]At multi-user stage:
- [/u] init -> starts getty/agetty
- getty/agetty -> starts console logins
Changing the arguments passed to X at start changes what X runs with it; default is either a login manager or a window manager. You have to edit that (I have no example of a specific edit).
One option is to edit the startup of the standard X init file location in “/etc/X11” and let the normal X startup use that. The other option is to start X independently with your own configuration directly naming what you want started with it (this would mean having getty/agetty start X with your arguments instead of those of “/etc/X11”). The decision on which to choose would be related to whether you want just this application to run, or if you want your application to run within a windowing environment (see that URL listed above).
Startx is somewhat of a hybrid. systemd or init scripts normally tell getty to replace a console session with an X graphical session based on “/etc/X11” files. Startx is intended for manual start and offers some command line customization, but I think it still uses some of “/etc/X11” unless your options override (one part which startx does not do from “/etc/X11” is run a login manager…startx directly starts as the user running startx). Note that startx is a human-readable script…you can walk through this to see how it is done and then manually create your own startx style script.
To emphasize, X is just a program which starts with arguments like any other program. The init process is configured to start with a login manager argument unless autologin occurs, in which case X starts instead with a window manager argument (and sudo some user). Manual login at the login manager replaces an existing X session running a login manager with an X session using a window manager (sudo user). If at any point you change the arguments to X then you change what it spawns with…the trick is deciding where you want to intercept it.
To know what occurs automatically you’d need to study how getty/agetty is started and configured.