Getting rid of your display mananger
In a typical Linux desktop install, a display manager is used to ask your password when the system starts in a fancy GUI. Once you have entered the correct password, it will go on and start the window manager of your choice. If your computer is only for use by people who are not scared by terminals, you can remove your display manager because it is just one more thing that will confuse you when your system boots and all you see is a blinking _
in the top left corner.
And after all, who doesn’t want a login screen that is as minimalistic and simple as:
Arch Linux 4.15.14-1-ARCH (tty1) mobius login: _
Starting X with startx
startx
is just a nicer front-end to xinit
that allows starting a single session of the X window system. By default it will look for a .xinitrc
1 and execute that file with the shell once it has an X session.
This file should have a line of the form exec window-manager
which starts the window manager of choice. i3
for i3wm, startkde
for plasma, check the documentation of your WM to see how to start it. Your .xinitrc
should also include all the lines except the last block form /etc/X11/xinit/xinitrc
.
In my case, my .xinitrc
ends with
exec i3
Removing your display manager
Before really deleting our display manager we first test out if we can boot without it. To test this out, disable your display manager:
systemctl dissable sddm
Replace sddm
with your display manager (lightdm
, gdm
, …)
Now reboot, you should see a prompt asking for your username and password. Once you logged in, issue the following command
startx
If your window manager starts, great! You can now go on and uninstall your display manager.
If it doesn’t check your log files referred to in the error messages to find out what has gone wrong. If you can’t get it functioning, you can re-enable your old DM with systemctl enable sddm
.
Auto startx
Don’t want to type startx
every time you log in? append following lines to your .bash_profile
(or .zprofile
if you use zsh).
if [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then
exec startx # remove the exec to remain logged in when your wm ends
fi
This will automatically start your WM when you log in from the first teletypewriter (tty1
). When X is killed you are logged out.
What does exec
do?
Our .xinitrc
uses exec
to start the window manager. The reason it does this is to ensure that your Xsession stops when the window manager stops and keeps on running when it did not yet stop. From the documentation we learn what exec
does:
If
exec
is specified with command, it shall replace the shell with command without creating a new process. If arguments are specified, they shall be arguments to command. Redirection affects the current shell execution environment. – man exec
In other words, if the program after exec
ends your program will end. If this program is your shell, as is the case in the example of auto startx
, you will be logged out because your shell will be terminated when your WM terminates.
Extra
My full .xinitrc
is
#!/bin/sh
userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap
# merge in defaults and keymaps
if [ -f $sysresources ]; then
xrdb -merge $sysresources
fi
if [ -f $sysmodmap ]; then
xmodmap $sysmodmap
fi
if [ -f "$userresources" ]; then
xrdb -merge "$userresources"
fi
if [ -f "$usermodmap" ]; then
xmodmap "$usermodmap"
fi
# start some nice programs
if [ -d /etc/X11/xinit/xinitrc.d ] ; then
for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
[ -x "$f" ] && . "$f"
done
unset f
fi
exec i3
Sources
- The
xinit
,startx
andexec
man pages - The archwiki page on xinit
-
Well actually, first
.startxrc
followed by.xinitrc
↩