Note: This tutorial is deprecated and replaced by CustomizeGuestSession.
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 attached to this tutorial:
- guest-session-prefs-0.13.tar.gz - for Ubuntu < 11.10 with GDM
- 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.
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.
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.
There is a tarball file attached to this tutorial 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.
Now you have exactly the same setup as I have (or at least had when I wrote this...). These are the installed files:
Open a terminal window and go to the directory with the downloaded file
tar -xf guest-session-prefs-0.13.tar.gz
You launch a guest session by calling
/usr/share/gdm/guest-session/guest-session-launchor, as from Ubuntu 11.04, just
guest-sessionIf 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:
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.
That code tells Firefox to not prompt about remembering passwords. At the page Customizing Mozilla you find some other customizing hints.
echo 'user_pref("signon.rememberSignons", false);' >> $profiledir/user.js
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:
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.
disable_app libcanberra-login-sound.desktop /usr/share/gnome/autostart
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.
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:
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.
echo "fr_FR" > /tmp/guest-session-lang
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.
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.
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-sessionIn comment #23, Paul has elaborated this approach by providing a step-by-step guide. Thanks, Paul!
sudo cp -ri /etc/skel /etc/guest-session
I have submitted the bug Premature lock when launching guest session, whose implementation would support this approach to customizing guest sessions.