How do I replace the desktop by an application?

Replacing Desktop By An Application

Define User Defined Session

First we will have to define a User Defined Session that handles the special case when no desktop should be loaded. We will define this session by creating a custom.desktop file in /usr/share/xsessions/ with a content similar to this:

[Desktop Entry]
Name=Custom
Comment=Custom Session to run ~./.xsession
Exec=/home/<username>/.xsession
X-Ubuntu-Gettext-Domain=<gnome-session-3.0>

This will tell GDM to run the script .xsession located in the HOME of the user <username>.

Optional X-Ubuntu-Gettext-Domain is needed for a correct language translation in case we load Unity/GNOME desktop later (replace with gdm in 10.04).

Make A Script To Start

This script ~/.xsession could look as simple as that:

#! /bin/bash

xterm
logout

Load Custom Session On Login

If we now define to load our session "Custom" during the given user's login at the gdm screen only the X-Terminal will be started and we will be back at gdm on exit. Next time we login as the user this setting will be remembered as default.

Run Application That Need Windows-Managing

Of course we are not yet able to run an application that needs a windows manager such as GNOME. To do this replace the .xsession script by something like:

#! /bin/bash

gnome-wm &
firefox
logout

We can see that the GNOME windows manager is now loaded but no desktop elements are present. This enables an application (e.g. firefox here) to start.

But take care what you do: If we minimize the application to the non-existent tray we will end up with a nice wallpaper to look at. Because of this it is very important to include logout at the end of the script to logout the session after the application terminated. There really is no other programm running to do this for you until you add one to your script. You deliberately replaced your desktop by firefox only (a bad idea).

Of course we would also be able to start gnome-desktop or gnome-session (resp. options) from the script but this is what we already do by default.