32

Sometimes it may be needed that a user only has access to a certain application. Running the desktop environment then may be unwanted be it either for security reasons or for acchieving a better accessibility to the given application.

In these cases it may be desired to replace the desktop by an application that runs immediately after login.

Other users should have a normal access to their desktops.

1 Answer 1

38

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.

2
  • Just one problem with the full screen in custom sessions. See question askubuntu.com/questions/184610/…
    – Juzer Ali
    Sep 6, 2012 at 7:09
  • Your solution creates a session seen by all users, but running a script of a specific user. -- Not ideal. Sep 19, 2016 at 10:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .