Ok another thread in the forum, brought this to mind, (Wizard10000) mentioned that the only display manager which doesn't launch-run X as root is GDM. This is likely to be irrelevant in future, with Wayland and honestly I don't overly care as it is anyway but still on with the thread.
1. Using systemd to autologin a user.
Create a directory named getty@tty1.service.d and a file in it called override.conf in the following location.
Code: Select all
/etc/systemd/system/getty@tty1.service.d/override.conf
That's what it'll do, automatically login the user named, where it says yourusername. Put the desired username there.[Service]
Type=simple
ExecStart=
ExecStart=-/sbin/agetty --autologin yourusername --noclear %I 38400 linux
2. To automatically startx edit the .profile file in your users /home directory and add this to the bottom.
Code: Select all
#Startx Automatically
if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
. startx
logout
fi
3. Now say you have several DE's/WM's installed. You'll obviously want to be able to pick and switch between them. This is where update-alternatives comes into it.
Enter the following command to pick which will be the default xsession, until it's changed.
Code: Select all
sudo update-alternatives --config x-session-manager
Code: Select all
sudo update-alternatives --install /usr/bin/x-session-manager x-session-manager /usr/bin/startfluxbox 40
NOTE: Ok another scenario, the above is perfectly fine for a single user system but what about a multi-user one or one on which you want to be able to login more than one username. Easy, peasy, just skip step 1 (or remove the directory/override.conf file. You'll be met with a command-line login to enter the user and password you want to use.
Finally, you likely already have a display manager running. For all this automagic-ness to work, you'll have to change that. Couple options, remove the display manager from your OS, you can always reinstall it later if desired. Another would be to use "sudo systemctl disable lightdm" to disable lightdm and keep it from automatically starting every time the system boots up. If at some point in future you wish, re-enable the sucker with "sudo systemctl enable lightdm" and you may also need to run "sudo dpkg-reconfigure lightdm" too. After which the sucker should be up and running again.
IMPORTANT NOTE: Make sure you have the xinit package installed "dpkg -l |grep xinit" if not yep, install it ! "sudo apt install xinit", just found out the hard way I didn't have the stupid thing on a 32b/Stretch minimal netinstall OS when went to remove lightdm and set this junk up. Kept getting problems until did the above and installed the dang xinit = startx command.