2010-02-20

How to try the GDM login screen in many resolutions

This blog post explains how to try the GDM login screen and make screen shots in any, user-specified screen resolution. This can be useful when designing GDM themes. The instructions were tried on Ubuntu Hardy (8.04), but they should work on Ubuntu Intrepid (8.10) and Ubuntu Jaunty (9.04). They won't work on Ubuntu Karmic or Ubuntu Lucid, because they contain GDM 2, which doesn't have the --xnest feature implemented (** (gdmflexiserver:18758): WARNING **: Not yet implemented). Installation instructions:

  1. (When asked to run a command, run it in a terminal window.)
  2. Make sure GDM is your display manager. Since GDM is the default, chances are that it is. To make sure, run sudo dpkg-reconfigure gdm, and select GDM if it asks you.
  3. Log in using GDM if you haven't already done so. To do that, run sudo /etc/init.d/gdm restart . (You will lose your X11 session doing so.)
  4. Install Xephyr, a modern nested (embedded) X server, similar to Xnest: sudo apt-get install xserver-xephyr
  5. Install ImageMagick for making screen shots in various image file formats: sudo apt-get install imagemagick
  6. Try Xephyr: Xephyr :9 -screen 800x600 -extension RANDR . A new window should appear with the usual a black-and-white diagonal background and a diagonal cross-shaped cursor. Abort Xephyr in the terminal window. Try with different -screen sizes.
  7. Find your GDM Xnest command line by running grep ^Xnest= /etc/gdm/gdm.conf . You should see something like Xnest=/usr/share/gdm/gdmXnestWrapper -br -audit 0.
  8. Create a new xnest wrapper script:
    echo '#!/bin/sh
    GEOMETRY="`cat /tmp/new-xnest-geometry`"
    GEOMETRY="${GEOMETRY:-800x600}"
    exec Xephyr "$@" -screen "$GEOMETRY" -extension RANDR' |
    sudo tee  /usr/local/sbin/gdm-xnest &&
    chmod 755 /usr/local/sbin/gdm-xnest
  9. Create the screenshot helper script:
    echo '#! /bin/bash --
    # by pts@fazekas.hu at Sat Feb 20 11:09:20 CET 2010
    GOT=($(ps x | perl -ne '\''if (/[ ]Xephyr :/) {
      $c++;
      print"$1 $2\n" if (/[ ]Xephyr :(\d+)(?= ).* -auth (\S+)/)}
      END{die"Xephyr not found\n"if!$c;die"multiple Xephyrs found\n"if$c>1}'\''))
    test "$?" = 0 || exit "$?"
    if test ${#GOT} != 2; then
      echo "Xephyr detection failed" >&2
      exit 90
    fi
    export DISPLAY=":${GOT[0]}" XAUTHORITY="${GOT[1]}"
    exec import -window root "$@"' |
    sudo tee -a    /usr/local/bin/xephyr-import &&
    sudo chmod 755 /usr/local/bin/xephyr-import 
  10. Change the Xrandr= setting in /etc/gdm/gdm.conf to use the new wrapper script: sudo perl -pi -0777 -e 's@^Xnest=.*@Xnest=/usr/local/sbin/gdm-xnest -br -audit 0@gm' /etc/gdm/gdm.conf
  11. Make sure the Xrandr= setting is changed: check that running grep ^Xnest= /etc/gdm/gdm.conf displays Xnest=/usr/local/sbin/gdm-xnest -br -audit 0
  12. Save your work in your X11 session, and restart GDM: sudo /etc/init.d/gdm restart . (You will lose your X11 session doing so.)
Usage instructions (how to show the GDM login dialog inside a window, and how to make a screen shot):
  1. If not already logged in, login in at the GDM login screen.
  2. Run gdmflexiserver --xnest to get the GDM login dialog inside a window of your regular session. You can specify the window size using e.g. echo 1024x768 >/tmp/new-xnest-geometry && gdmflexiserver --xnest
  3. To make a JPEG screen shot, run xephyr-import -quality 75 screenshot.jpg while the Xephyr window with the GDM login screen is still open.
  4. To make a PNG screen shot, run xephyr-import screenshot.png .

No comments: