Wednesday, August 16, 2006

Login Screens for GDM

Not long ago, I learned how to change the Gnome Display Manager (GDM) login theme. You know, the picture that comes up when you boot the computer, asking for your username and password.

At the time, I didn't know anything about creating a login screen. It looks like it ought to be simple. Find a picture, blow it up to the appropriate size, add some text.

One of the login themes I had downloaded was the USS Enterprise from Star Trek. Well, it's the NCC-1701A rather than the good-old NCC-1701, but it will do. You download this as a tarfile, gdm-ncc1701a-default.tar.gz, and load it with sudo /usr/sbin/gdmsetup .

OK, so what's in the tarfile? Let's take a look:

$ tar tvzf gdm-ncc1701a-default.tar.gz 
drwxr-xr-x u       0 2003-06-03 11:36:14 enterprise-1701-A/
-rwxr-xr-x u  582242 2003-06-03 07:18:28 enterprise-1701-A/splash.jpg
-rw-r--r-- u   46781 2003-06-03 11:21:01 enterprise-1701-A/screen.png
-rw-r--r-- u     164 2003-06-03 11:09:07 enterprise-1701-A/GdmGreeterTheme.desktop
-rw-r--r-- u    7715 2003-06-03 11:33:03 enterprise-1701-A/icon.png
-rw-r--r-- u   21082 2003-06-03 11:36:14 enterprise-1701-A/1701a.xml

The tarball has a directory enterprise-1701-A, inside of which are several files. I'm not going to go into detail about the files, you can read all about it elsewhere. Basically, we've got:

  • GdmGreeterTheme.desktop, which holds the name of the theme, the creator, the copyright (if any), and a pointer to
  • 1701a.xml, the heart of the theme. We'll look at this more in a minute.
  • splash.jpg, the actual picture for the background of the login screen. If you can download the picture at 1280x1024 resolution, do so. The greeter program will shrink everything for smaller screens.
  • screen.png, which serves as an icon used gdmsetup to give you a basic idea of what the theme looks like. I typically use a reduced (200x160) version of splash.jpg, but that's your call.
  • icon.png This is the icon which is used to mark your various login options. In Ubuntu these are typically Option, which selects the language, Session, which determines the window manager, and System which allows you to hibernate/reboot/restart. You can use different icons for these functions, in which case you have multiple icon files, all with (of course) different names.

Now for the fun part. In GdmGreeterTheme.desktop there will be a line


Where xxxxx.xml is the file that controls the look and feel of the login screen. There are many options to this, but for our purposes we'll just modify the one from the Enterprise theme.

  • For my purposes, I wanted white text, so I looked through the file and changed all the lines that said normal color=#0000ff (blue) to normal color=#ffffff (white).
  • I also wanted a slightly bigger font, so I changed the font="Sans 14" to font="Sans 16".
  • The message text can be changed. Look for a box that says <text>Welcome to %h</text>. Change this to the message you desire. Note that %h is the name of the machine. You should translate the message into all the languages listed, but I haven't tried that. (How you you say "Resistance is Futile" in Polish?)
  • There is also a line which says "pos anchor ...", which gives the location of the box with the login message. The x and y coordinates are given as percentages. You'll have to play with these until you get something you can live with.
  • You can play the same sort of game with the icons, including changing their spacing and orientation (from a horizontal array to vertical).
  • When you've done all that, you naturally want to see what the thing looks like. You could select it with gdmsetup then log off, but that's time wasting. Instead, there is a command, gdmthemetester, which handles all of that. To look at the theme in the e.g. newscreen directory, go one step above that directory and type
    $gdmthemetester console newscreen
    and you'll see a representation of the the screen, in a somewhat reduced form. If you like, you can capture this picture to form the screen.png file mentioned above.
  • Put all of these files into one directory, then form a gzipped tarball of the entire directory:
    $ tar cvf newsceen.tar.gz newscreen
    if your directory is named newscreen. gdmsetup can then be used to install this theme.

I put the login screens I've "created" online. Let me know what you think of them.

Oh, heck, samples are probably in order: