[Contents]

Copyright © 2015 jsd

Display manager, session manager, and window manager
John Denker

1  Introduction

There are three categories of things:

  1. Display manager: Depending on runlevel, the system may start a display manager on the terminal. It handles graphical logins. Mnemonic: If used, it owns the display during times when nobody is logged in.

    Example: lightdm is a display manager, and gdm is another.

    In contrast: There are a lot of things that can go wrong with a display, so for machines that I care about, I set it up so that runlevel 2 does not start a display manager. Instead, there is a text-mode login.

  2. Session manager: This is what draws the desktop. The window manager draws a frame around the window. It allows you to drag the window around on the desktop. By puttings stuff in your  /Desktop directory it keeps track of what sort of icons should appear on the desktop.

    Example: gnome-session is a session manager. Read the manpage for gnome-session for more information.

  3. Window manager: This is what draws borders around the windows. It allows you to drag windows around on the desktop. It allows you to stack windows one in front of another.

    Example: compiz is a compositing window manager. Metacity is an another window manager. Metacity is older, simpler, more reliable, and places less of a burden on the graphics system and CPU. Allegedly mutter is another window manager, but I’ve never gotten it to work.

    Ubuntu tries to make you use compiz, which is a problem if compiz is broken. A workaround is discussed in section 2.

2  How to Work Around a Broken Window Manager

Sometimes compiz is broken. I’ve seen this happen far too many times.

When the window manager is broken, the windowing system is unusable or nearly so. You may have no command prompt and no easy way of getting one. (This is one of the many reasons why it is nice to have a text-mode login available, as mentioned in section 1 and detailed in section 3.)

To verify that the symptoms are caused by a broken window manager, you can read your  /.xsession-errors file. If it contains something like the following, you know you’ve got a broken compiz:

compizconfig - Info: Backend     : gsettings
compizconfig - Info: Integration : true
compizconfig - Info: Profile     : Default
x-session-manager[2603]: WARNING: App 'compiz.desktop' exited with code 1
x-session-manager[2603]: WARNING: App 'compiz.desktop' respawning too quickly
x-session-manager[2603]: CRITICAL: We failed, but the fail whale is dead. Sorry....
compiz (core) - Info: Loading plugin: core
compiz (core) - Info: Starting plugin: core
compiz (core) - Info: Loading plugin: ccp
compiz (core) - Info: Starting plugin: ccp
compiz (core) - Info: Loading plugin: composite
compiz (core) - Info: Starting plugin: composite
compiz (core) - Info: Loading plugin: opengl
compiz (core) - Info: Starting plugin: opengl
compizconfig - Info: Backend     : gsettings
compizconfig - Info: Integration : true
compizconfig - Info: Profile     : Default
x-session-manager[2603]: WARNING: App 'compiz.desktop' respawning too quickly
x-session-manager[2603]: WARNING: App 'compiz.desktop' exited with code 1
x-session-manager[2603]: WARNING: App 'compiz.desktop' respawning too quickly

I have no idea why compiz is failing.

The simplest way forward is to forget about compiz and use metacity instead. It is less fancy but perfectly reasonable.

Here are some of the required steps:

  1. apt-get install gnome-session-fallback

    This brings in the metacity window manager, and some configuration files that can be used to tell gnome-session that we want to use metacity instead of compiz.

    The configuration files are stored in /usr/share/gnome-session/sessions on my machine.

  2. If you are starting your gnome-session by means of a display manager, you can click on the gnome “footprint” icon and tell it that you want to use a fallback (or flashback) style of session.
  3. On the other hand, if you are using a text-mode prompt and are starting the gnome-session by means of the startx command, a dramatically different process is used for starting the session.

    The key is to pass the --session=gnome-fallback argument to gnome-session. I did this by editing the file /etc/X11/Xsession.d/99x11-common-start from

    echo "$STARTUP" > /tmp/foobar
    exec $STARTUP
    

    to

    echo "$STARTUP" > /tmp/foobar
    exec $STARTUP --session=gnome-fallback
    

    That seems like a bit of a hack, but I couldn’t think of any cleaner way of doing it

Also note: Your .xinitrc is probably calling (directly or indirectly) x-session-manager.

However:
  /usr/bin/x-session-manager
is a symlink to
  /etc/alternatives/x-session-manager
which is a symlink to
  /usr/bin/gnome-session
which is an actual session manager.

3  Text-Mode Login

As mentioned in section 1, for machines that I care about, I like to set it up so that in runlevel 2 there is no display manager. Instead there is a text-mode login.

Once I am logged in, if I want to start a windowing system, I can always give the startx command.

Here is an outline of how to set this up. Let’s use lightdm as an example; gdm is very similar.

  1. It is likely that your distro gave you a file /etc/init/lightdm.conf containing the following provisions:
      start on ((filesystem
                 and runlevel [!06]
                 and started dbus
                 and plymouth-ready)
                or runlevel PREVLEVEL=S)
    
      stop on runlevel [016]
    

    You need to change that to something like

      start on (filesystem
                 and runlevel [345]
                 and started dbus
                 and plymouth-ready)
      stop on runlevel [!345]
    

    I have no idea what the ‘plymouth-ready’ event signifies. Let’s leave it alone.

  2. Meanwhile, you presumably also got a file /etc/init/plymouth-stop.conf containing the following provisions:
    start on (starting gdm
              or starting kdm
              or starting xdm
              or starting lxdm
              or starting lightdm
              or starting uxlaunch
              or starting ubiquity
              or starting oem-config
              or stopped rc RUNLEVEL=[2345]
              or starting rcS
              or starting mountall-shell)
    

    You need to add a term involving runlevel 2, so it looks like:

    start on (starting gdm
              or starting kdm
              or starting xdm
              or starting lxdm
              or starting lightdm
              or starting uxlaunch
              or starting ubiquity
              or starting oem-config
              or runlevel 2
              or stopped rc RUNLEVEL=[2345]
              or starting rcS
              or starting mountall-shell)
    

    If you skip this step, ugly things are going to happen when you boot into runlevel 2. The boot process will peter out, but no login prompt will appear, because plymouthd still owns the display. You can salvage the situation by hitting Alt-F4 ... but if you’re smart enough to think of that, you should be smart enough to prevent such a situation from arising. It’s simple: make sure plymouthd stops and the display-manager doesn’t start.

    Here is the diff:

    commit d1d713023430fa3ad7a9c31b77bb21a7b5077fc0
    Author: John Denker <jsd@av8n.com>
    Date:   Sun Mar 22 18:48:36 2015 -0700
    
        setup for text-mode login in runlevel 2
    
    diff --git a/lightdm.conf b/lightdm.conf
    index ff9201d..4dc0f6f 100644
    --- a/lightdm.conf
    +++ b/lightdm.conf
    @@ -8,13 +8,12 @@
     description "LightDM Display Manager"
     author  "Robert Ancell <robert.ancell@canonical.com>"
    
    -start on ((filesystem
    -           and runlevel [!06]
    +start on (filesystem
    +           and runlevel [345]
                and started dbus
                and plymouth-ready)
    -          or runlevel PREVLEVEL=S)
    
    -stop on runlevel [016]
    +stop on runlevel [345]
    
     emits login-session-start
     emits desktop-session-start
    diff --git a/plymouth-stop.conf b/plymouth-stop.conf
    index 8b86725..c68e9e1 100644
    --- a/plymouth-stop.conf
    +++ b/plymouth-stop.conf
    @@ -13,6 +13,7 @@ start on (starting gdm
               or starting uxlaunch
               or starting ubiquity
               or starting oem-config
    +          or runlevel 2
               or stopped rc RUNLEVEL=[2345]
               or starting rcS
               or starting mountall-shell)
    
    
[Contents]

Copyright © 2015 jsd