Thursday, September 10, 2009

How To Create A GDM Theme

GDM is the GNOME Display Manager, a graphical login program, which provides a simpler alternative display manager for the X Window System's XDM. GDM is released under the GNU General Public License (GPL).
The X Window System by default uses the XDM display manager. However, resolving XDM configuration issues typically involves editing a configuration file. GDM allows users to customize or troubleshoot settings without having to resort to a command line. Users can pick their session type on a per-login basis. GDM also features easy customization with themes.

Components of a GDM theme
A GDM Theme is basically composed of:
  • A background image
  • A screenshot
  • Icons and other artwork
  • An xml file, where the actual theme is defined
  • The GdmGreeterTheme.desktop file
Creating your own theme
It's easier to modify an existing theme, rather than doing it from scratch. In general, the first item to be changed is the background image. The background image must be at least as big as the screen resolution. In order to make the theme suitable to other users, it is a good idea to use at least 1600x1200 pixel images, as they look sharp even on high-resolution screens. A small image can also be used, but it will loose quality when expanded. The image must be placed in the theme directory and declared in the xml file as follows:

Next, you will have to reposition your prompts, menus, labels and icons in order to match your background image. You can define images, rectangles and labels with the following tags (respectively):


Using the item tag, you can also specify the location of option buttons, system messages, login screen, etc, by adding id= to the item tag. All the GDM system tags I am aware of are:

Use the pos tag within each item section to define its x,y position and make sure it all looks in harmony with your background image. Finally, the xml file must be declared in the GdmGreeterTheme.desktop file as follows:

Greeter=theme.xml

Capturing your GDM screen
Once your theme is complete, you will need to install the theme in order to obtain a screenshot. Install your new theme in your Login Screen Manager by selecting System > Administration > Login Window > Local(tab) > +Add and select your new theme. Then check the radio button next to it in the list and click the Close button.
I remember taking screenshots of the GDM screen in other distros using the below command, but this command didn't work on my Ubuntu 9.04 system:

chvt 7 ; sleep 5 ; XAUTHORITY=/var/gdm/:0.Xauth DISPLAY=:0.0 import -window root /tmp/gdm-shot.png

An easier way to capture your GDM screen would be to use xnest, this worked perfectly for me. Open a terminal and install xnest with the command:
(assuming you don't already have xnest installed):

sudo apt-get install xnest

Then run xnest with the command:

gdmflexiserver --xnest

This will open a new window and show your GDM login screen. Now just hit the "Print Screen" button on your keyboard and save the screenshot. Open the newly created screenshot in your favorite image editor and shrink the screenshot down to 188x140. Now put the screenshot in your theme directory and make a reference to it in your GdmGreeterTheme.desktop, adding your theme name, description, author name, screenshot and copyright fields as follows:

[GdmGreeterTheme]
Greeter=theme.xml
Name=The name of your theme
Description=The description of your theme
Author=Your name
Screenshot=screenshot.png
Copyright=Copyright information

Conclusion
The final step is to package your new GDM theme with the command:
tar czf MyTheme.tar.gz MyThemeDir
The new theme can bow be installed on any computer from the GDM Configuration Screen.