Tag/tag.png

Unsupported Version
This article applies to an unsupported version of Ubuntu. More info...


This tutorial is deprecated and replaced by CustomizeGuestSession.


Important note

Up to Ubuntu 11.04 the guest session feature was provided by gdm-guest-session, an extension to the GNOME Display Manager (GDM) which was the default display manager in Ubuntu. This changed in Ubuntu 11.10, where LightDM is the default display manager, and you can now launch a guest session through a built-in LightDM feature. Unlike before you don't need to first log in as a regular user; a guest session in Ubuntu >= 11.10 can optionally be launched directly from the login screen.

This tutorial was written with gdm-guest-session in mind. However, I have put together a new tarball file, so now there are two tarballs available:

  1. guest-session-prefs-0.13.tar.gz - for Ubuntu < 11.10 with GDM

  2. guest-session-prefs-lightdm-0.12.tar.gz - for Ubuntu >= 11.10 with LightDM

Even if the comments below refer to the first tarball, most of them apply to the new tarball as well. The names of some files and directories have been altered, but hopefully the README file in guest-session-prefs-lightdm-0.12.tar.gz contains sufficient guidance in that respect.

Overview

Many Ubuntu users, me included, have posted ideas on minor changes to the gdm-guest-session behavior, and I'm happy to share the guest session related changes I have made. They include:

  • Firefox preference setting
  • disabling login-sound
  • language selection [not in LightDM]
  • gettexted strings
  • folder for storing files permanently
  • info dialog at startup
  • icon on the desktop

Whether you want to make a couple or all of those changes, or there are other changes that you would like to see, I hope that the methods used for altering the guest session behavior may serve as useful examples.

The figure below shows the most important files, and gives you a schematic picture of the program flow. In the left column you find the core files in the gdm-guest-session package (green borders) together with a tiny file that I created, merely to have all the executables located in the same folder. The files in the right column are in effect configuration files, even if they contain shell commands. Computer owners and system admins may edit the files in /etc/guest-session to their liking, without worrying about the changes being overwritten when gdm-guest-session or other packages are updated.

../guest-session-model.jpg

Some of the commands in my code snippets need to be executed before the start of the launch process, while others are better executed in the middle or at the end of the process. I grouped my snippets accordingly, so that's why there are three files in the right column.

Tarball: guest-session-prefs

There is a tarball file with both a README file and an install script, almost like a package. But since admins are expected to change and add things, guest-session-prefs is very different compared to an Ubuntu package. In the README file I call it a "convenience kit", a framework for configuring guest sessions.

I recommend that you download the tarball and run the install script. Rather than describing every detail, the comments below serve as a user guide focusing on a few edit possibilities.

Install / uninstall

Okay, here we go.

  • Download guest-session-prefs-0.13.tar.gz
    Open a terminal window and go to the directory with the downloaded file

      tar -xf guest-session-prefs-0.13.tar.gz
      cd guest-session-prefs-0.13
      sudo ./install.sh

Now you have exactly the same setup as I have (or at least had when I wrote this...). These are the installed files:

  /etc/guest-session/auto.sh
  /etc/guest-session/prefs.sh
  /etc/guest-session/prepare.sh
  /etc/guest-session/sv/LC_MESSAGES/guest-session-prefs.mo
  /usr/share/doc/gdm-guest-session/guest-session-prefs/README
  /usr/share/doc/gdm-guest-session/guest-session-prefs/sample-translation.po
  /usr/share/doc/gdm-guest-session/guest-session-prefs/uninstall.sh
  /usr/share/gdm/guest-session/guest-session-auto.sh

You launch a guest session by calling

  /usr/share/gdm/guest-session/guest-session-launch

or, as from Ubuntu 11.04, just

  guest-session

If you, like me, display a list dialog with choices when a guest session is launched, you'll notice an odd behavior if you use the guest session menu item provided by the indicator-session package. The reason is that indicator-session locks the screen before calling guest-session-launch. Creating your own launcher, e.g. via System -> Preferences -> Main Menu, solves that possible problem.

To uninstall guest-session-prefs you do:

  cd /usr/share/doc/gdm-guest-session/guest-session-prefs
  sudo ./uninstall.sh

Comments

Firefox

Maybe Firefox is the most used application by guests, and many admins want to be able to set some preferences. /etc/guest-session/prefs.sh contains a code snippet that creates a Firefox profile, and given the commands in that snippet, one line of code in prefs.sh is enough to change some aspect of Firefox.

  echo 'user_pref("signon.rememberSignons", false);' >> $profiledir/user.js

That code tells Firefox to not prompt about remembering passwords. At the page Customizing Mozilla you find some other customizing hints.

Disabling certain applications

guest-session-setup.sh disables a few services that are unnecessary for guest sessions. Applying the same approach, prefs.sh defines the function disable_app(). This is how I disable the login sound:

  disable_app libcanberra-login-sound.desktop /usr/share/gnome/autostart

libcanberra-login-sound.desktop is the file that autostarts the login sound by default, and /usr/share/gnome/autostart is the folder where that file resides.

Language selection [not applicable to LightDM]

If you launch a guest session right after having installed guest-session-prefs, you are prompted to choose between English and Swedish.

../lang-select-screenshot.png

If you try the Swedish option, but still only see English on the screen, it's hopefully not a bug. A more likely explanation is that Swedish has not been installed on your system. You can set available languages via System -> Administration -> Language Support.

For those of you who want to be able to select language, the language related code ought to be useful. If one language (e.g. French) is enough, but the launching regular session might be run in some other language, the code in /etc/guest-session/prepare.sh can be exchanged for:

  echo "fr_FR" > /tmp/guest-session-lang

Finally, if you have no interest in using more than one language, you can simply delete prepare.sh. OTOH, commenting out the code or renaming the file are probably better options. For instance, there may be other preferences that you want to set on-the-fly when launching a session.

Gettexted strings

To the extent you make use of text strings that are displayed to the guest user, which for instance is the case with the info dialog box shown below, you may want the strings to be translated to the current language. guest-session-prefs shows how that can be done using GNU gettext. If you have not used the gettext tools before, I believe that my example may help you get started. Of course, reading parts of the gettext manual is advisable in any case.

If you are only dealing with one non-English language, and don't care about English, it's probably easiest to drop gettext and just hard code the strings in the language of choice.

Folder for storing files permanently

I allow my guest users to store files permanently, and the install script creates the folder /var/guest-data for the purpose and assigns the permissions 0777. If you are of another view, just remove that folder.

Info dialog at startup

/etc/guest-session/auto.sh contains code for displaying an info dialog box. While calling the guest users' attention to the temporary nature of a guest session, it informs about the dedicated folder /var/guest-data for persistent file storage.

../guest-session-warning.png

Icon on the desktop

auto.sh also creates a shortcut icon to /var/guest-data. You may want to add a few similar code snippets to auto.sh that for instance place application shortcuts on the desktop.

Alternative approach

In some respects, launching a guest session comes about similarly to creating a new regular user, so by default the files in the folder /etc/skel are copied to the guest's home folder. As from Ubuntu 11.04, gdm-guest-session uses the files in /etc/guest-session/skel if present. That way some of the above customization measures can be accomplished by editing in /etc/guest-session/skel instead of using shell commands.

You enable this feature by copying /etc/skel/* to /etc/guest-session/skel/*:

  sudo mkdir -p /etc/guest-session
  sudo cp -ri /etc/skel /etc/guest-session

Related bug

I have submitted the bug Premature lock when launching guest session, whose implementation would support this approach to customizing guest sessions.

Readers' comments

Originally this tutorial was published at Ubuntu Forums. It's still there, together with readers' comments that you may want to review.

CustomizeGuestSession/old (last edited 2017-09-06 20:12:39 by ckimes)