Jérôme Belleman
Home  •  Tools  •  Posts  •  Talks  •  Travels  •  Graphics  •  About Me

Who Needs a Display Manager?

29 Jul 2012

When display managers get so large and complicated that they become slow, spend a lot of memory and turn buggy, you start wondering if you need one at all.

1 Display Managers and the Absence Thereof

A display manager not only manages X servers, it also lets you authenticate, choose a window manager and potentially other things, too. Linux gives you a choice of display managers – GDM, LightDM, XDM – and even the choice of not having one at all. In this case, booting up your system will instead take your to the console which will also prompt you for a username and password.

2 Starting Your Graphical Environment without a Display Manager

A mite too rudimentary, you would say? How do I use my window manager, you may ask? Once logged in, all you need is run the startx command which effectively runs in an X session of yours all the commands that your will write to your ~/.xinitrc. Far from rudimentary, then, as this approach gives you infinite freedom as to how you start you graphical environment.

It goes beyond just running the command spawning your window manager. Being a mere shell script, you can also use it to export environment variables that will be accessible by all children processes or conditionally start other programs that make up your environment:

xrdb ~/.Xresources
xsetroot -solid black
nm-applet &

GPGAGENTINFOFILE=~/.gpg-agent-info
if [ -f $GPGAGENTINFOFILE ]; then
    . $GPGAGENTINFOFILE
fi
gpg-agent
if [ $? -ne 0 ]; then
    eval $(gpg-agent --daemon --write-env-file $GPGAGENTINFOFILE)
fi

fvwm

The ~/.xinitrc file is to startx what the ~/.xsession file is to display managers. To the point in fact, that my ~/.xsession file is nothing more than a symbolic link to my ~/.xinitrc file. Note how some command lines have a trailing & and some don't; programs like xrdb, xsetroot and gpg-agent will exit almost immediately, whereas some other ones will stay in the foreground until you interrupt them, like nm-applet and fvwm. Of course, in that last case, fvwm is the last command I run, the window manager, in which I will spend the rest of my time for the whole duration of my X session, so it doesn't need to be sent to the background with an &.

3 Multiple X Sessions

I was jealous of Window XP when I saw one could switch to another user graphical environment without logging the current one out. But in fact, it's something that was there in Linux all along. If you've got an X session running and need another one, just hit CTRL ALT F2 and log in as yourself or another user. Then run:

startx -- :1

Everything after -- are server options and :1 is the second display to start X in. Running startx without specifying the display would have assumed :0. With :1, CTRL ALT F8

will take you to your new X session. CTRL ALT F7 will take you back to the old one.

4 Reference