"Linux Gazette...making Linux just a little more fun!"


Configuring XDM -- a graphical login interface for Linux or UNIX

By Mark Nielsen


If this document changes, it will be available at The Computer Underground: http://www.tcu-inc.com/mark/articles/Kickstart.html.
CHANGES:
  1. Changed XServers File located at /etc/X11/xdm/Xservers by adding these lines to get 4 xdm sessions running so that 4 different people can log in. It seems like all the neat stuff only happened on the last session. It is probably easy to fix this. Perhaps I will mention it in the next article.
    :0 A local /usr/X11R6/bin/X :0
    :1 B local /usr/X11R6/bin/X :1
    :2 C local /usr/X11R6/bin/X :2
    :3 D local /usr/X11R6/bin/X :3
    

  1. Resources
  2. What is XDM? -- the graphical login interface
  3. My configurations
  4. Conclusion

Resources

  1. Chris Carlson's article in the Linux Gazette.
  2. man xdm
  3. My old xdm cheat sheet back in 12/1996 when I was just a hacker (in the good sense). I guess this was around right when the Gazette got started? How time flies. I should have posted this there at that time.

What is XDM?

To put it simply, xdm is just a graphical login screen so that you can impress your boss or friends that you don't have some boring console to look at when your computer starts up. It just makes Linux a little bit more cool than someone might have previously thought.

In theory, most of configurations here should work for any Linux distribution. This is configured for RedHat 6.0 though. RedHat 6.0 uses gdm instead of xdm when it starts its graphical login screen. However, I haven't got gdm to work in the exact way I want it, even though it seems much better than xdm. Once I figure out a few things, I will write a brief article on gdm also.

Here are some things to note ,

  1. If you want xdm (or gdm) to start when you computer starts, you need to make sure this line
    id:3:initdefault:
    Looks like this
    id:5:initdefault:
    in the file "/etc/inittab". Please, whatever you do, get Xwindows working before you set xdm to start at bootup. If Xwindows doesn't work, xdm won't work, and that can cause problems.
  2. RedHat 6.0 switched to gdm instead of using xdm which is apparent at the bottom of the /etc/inittab with the line
    x:5:respawn:/etc/X11/prefdm -nodaemon
    thus, change that line to this,
    x:5:respawn:/usr/bin/X11/xdm -nodaemon
  3. All the files I am changing are in "/etc/X11/xdm".

My config files

I am only interested in a few files, namely
/etc/X11/xdm/Xsetup_0
/etc/X11/xdm/Xresources
/etc/X11/xdm/GiveConsole
/etc/rc.d/rc.change_graphic
/etc/rc.d/rc.local
/etc/inittab <-- this was explained above
and the gif files in /etc/X11/xdm/graphics/

Here is the goal, I want to change xdm to make it so it has xeyes, santa, a clock, a graphics image, and my choice of background color on the desktop before someone logs in. After they log in, I want santa to die. Cruel huh?

Okay, let us do this in order:

  1. Copy my graphics perl script to "/etc/rc.d/rc.change_graphic". This changes the image which appears on the screen. Images are stored in /etc/X11/xdm/graphics as gif files.
  2. Copy my kill santa perl script to "/etc/X11/xdm/KillXsnow". This kills santa. Santa slows down the desktop.
  3. Copy my Xsetup script to "/etc/X11/xdm/Xsetup_0". Programs to run with the graphical login screen.
  4. Copy my Xresources script to "/etc/X11/xdm/Xresources". How the setup of xdm should look like.
  5. Copy my GiveConsole script to "/etc/X11/xdm/GiveConsole". Stuff to get executed before Xwindows is handed over to the user. Also, changes the background image for xdm.
  6. Add this command to "/etc/rc.d/rc.local". Make sure we get a graphics image to look at when we boot up.
  7. Copy my gif files to "/etc/X11/xdm/graphics/" and issue this command on the file
    tar -C / -zxvf xdm.tgz
    These are just my silly images I use.

Here are the rest of my config files:


Change graphics perl script

Located at "/etc/rc.d/rc.change_graphic". Issue the command "chmod 755 /etc/rc.d/rc.change_graphic" after it is copied.
#!/usr/bin/perl

@Files = </etc/X11/xdm/graphics/*.gif>;

#print @Files;

$Length = @Files;
$Seconds = `date +%S`;
chomp $Second;
$Frac = $Seconds/60;
if (!($Frac > 0)) {$Frac=1}

$Random = $Frac*$Length;
($Random,$Junk) = split(/\./, $Random,2);

if (($Random < 1) || ($Random > $Length -1))  {$Random = 1} 
$File = $Files[$Random]; 

$Rand2 = rand $Length;
($Rand2,$Junk) = split(/\./, $Rand2,2);

$Random = $Random + $Rand2;
if ($Random > $Length - 1) {$Random = $Random - $Length + 1;}

#print "$Length $Random $File\n";

if (-e "/etc/X11/xdm/xdm_front.gif") {system "rm /etc/X11/xdm/xdm_front.gif"}

if (@Files < 1)
  {
  ## Some sort of error messege should be here.  
  } 
else
  {system "ln -s $File /etc/X11/xdm/xdm_front.gif";}

Kill Santa perl script

Located at "/etc/X11/xdm/KillXsnow". Issue the command "chmod 755 /etc/X11/xdm/KillXsnow" after it is copied.
#!/usr/bin/perl

     ### I had to add the -a option between RH 5.2 and 6.0
@Temp = `cd /proc; grep -a ^/usr/X11R6/bin/xsnow /proc/[0-9]*/cmdline`; 

if (@Temp > 0) 
  {
  $Xsnow = shift @Temp;
  ($Junk,$ProcJunk,$No,$RestOfJunk) = split(?/?,$Xsnow);

     ## I am really paranoid that I want to kill the right pid 
  if (($No > 0) && ($Xsnow =~ ?^/proc/$No/cmdline:/usr/X11R6/bin/xsnow?))   
    {
#    system "echo \"Killing pid $No for Xsnow.\n\" > /tmp/1.txt\n";
    system "kill $No";
    }
  }

Xsetup_0 script

Located at "/etc/X11/xdm/Xsetup_0". Issue the command "chmod 755 /etc/X11/xdm/Xsetup_0". after it is copied.
#!/bin/sh
# $XConsortium: Xsetup_0,v 1.3 93/09/28 14:30:31 gildea Exp $
/usr/X11R6/bin/xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed -exitOnFail
#/usr/X11R6/bin/xbanner

    ### Santa and snowflakes
    ### On some installs, I am missing xsnow for some reason. 
/usr/X11R6/bin/xsnow -snowflakes 50 -santa 2 -unsmooth &

    ### Load the random image 
/usr/bin/X11/xloadimage -onroot -at 1,210 /etc/X11/xdm/xdm_front.gif -border brown  &

    ### A clock would be nice to see
/usr/X11R6/bin/xclock -digital -update 1 -fn -adobe-times-medium-i-normal--34-240-100-100-p-168-iso8859-1 -geometry +410+1 &

    ### Let us turn on xeyes
/usr/X11R6/bin/xeyes -geometry +410+100 &



Xrsources file

Located at "/etc/X11/xdm/Xresources". Issue the command "chmod 755 /etc/X11/xdm/Xresources" after it is copied.
! $XConsortium: Xresources /main/8 1996/11/11 09:24:46 swick $
xlogin*login.translations: #override\
        CtrlR: abort-display()\n\
        F1: set-session-argument(failsafe) finish-field()\n\
        CtrlReturn: set-session-argument(failsafe) finish-field()\n\
        Return: set-session-argument() finish-field()
xlogin*borderWidth: 3
xlogin*geometry: 400x200+1+1
xlogin*greeting: CLIENTHOST  
xlogin*namePrompt: login:\040
xlogin*fail: Login incorrect
#ifdef COLOR
xlogin*greetColor: CadetBlue
xlogin*failColor: red
*Foreground: black
*Background: #fffff0
#else
xlogin*Foreground: black
xlogin*Background: white
#endif
XConsole.text.geometry: 480x130
XConsole.verbose:       true
XConsole*iconic:        true
XConsole*font:          fixed

Chooser*geometry:               700x500+100+100
Chooser*allowShellResize:       false
Chooser*viewport.forceBars:     true
Chooser*label.font:             *-new century schoolbook-bold-i-normal-*-240-*
Chooser*label.label:            XDMCP Host Menu  from CLIENTHOST
Chooser*list.font:              -*-*-medium-r-normal-*-*-230-*-*-c-*-iso8859-1
Chooser*Command.font:           *-new century schoolbook-bold-r-normal-*-180-*

GiveConsole file

Located at "/etc/X11/xdm/GiveConsole".

All you have to do is add "/etc/X11/xdm/KillXsnow & " as the first command in the file. Mine looks like this,

#!/bin/sh
# Assign ownership of the console to the invoking user
# $XConsortium: GiveConsole,v 1.2 93/09/28 14:29:20 gildea Exp $

# By convention, both xconsole and xterm -C check that the
# console is owned by the invoking user and is readable before attaching
# the console output.  This way a random user can invoke xterm -C without
# causing serious grief.

/etc/rc.d/rc.change_graphic &
/etc/X11/xdm/KillXsnow &

chown $USER /dev/console
/usr/X11R6/bin/sessreg  -a -w "/var/log/wtmp" -u "/var/run/utmp" \
-x "/etc/X11/xdm/Xservers" -l $DISPLAY -h "" $USER


/etc/rc.d/rc.local file

Add this to the /etc/rc.d/rc.local file.
/etc/rc.d/rc.change_graphic

Conclusion

XDM is pretty cool. This is the old way of doing things. I recommend going to gdm or something else. For XDM, I give it a B-. It just lacks some of the stuff I always wanted to see that gdm has.

I will explain GDM next time. Gdm has the nice capability of letting you choose which desktop environment you want. In RedHat 6.0, you can choose KDE, GNOME, or other desktop environments when you login, which is pretty cool. Overall, I give gdm a B+, and if it becomes better documented, an A. Again, I hope to make an article about gdm for the August issue.


Mark works as a receptionist (shorts and tee-shirt) under Mike Hunter at The Computer Underground and as a professional (suit and tie) consultant at 800linux.com. In his spare time, he does volunteer stuff, like writing these documents.


Copyright © 1999, Mark Nielsen
Published in Issue 43 of Linux Gazette, July 1999


[ TABLE OF CONTENTS ] [ FRONT PAGE ]  Back  Next