HOW TO: Add Non-CDE Window Managers to CDE's Dtlogin

From the CDE FAQ:
 

Common Desktop Environment FAQ

3.1) How can I change my default window manager in CDE?

I asked if it were possible to add other window managers such as twm or fvwm to the CDE login.  I did get a few responses saying that it could be done, but unfortunately no one knew how.  I'm running fvwm right now.  All I had to do was put:

Dtsession*wmStartupCommand:   /home/orb/bin/sunos5/fvwm
in my .Xdefaults file, just change the path to wherever you put fvwm.

I hate to burst any die-hard CDE bubbles, but I'm a FVWM man.  Have been for years.  So when I first installed CDE on our system for the users, it irked me to no end that I would have to drop to the command line login in order to get my precious FVWM environment that I was so used to.  For me, I could not use the above fix, for even if I were to try, I still use ssh for doing work as root on remote machines, and I needed to start the ssh-agent before starting the X session. To make matters even more annoying, the CDE's login  never worked smoothly on our Solaris 2.5 machines -- the drop to command line login never works the first time, go figure.

So after searching high and low, and, barring that, hacking the darned thing myself, I managed to figure out how to add window managers to the CDE login.  Not only that, but as a bonus, I figured out how to add ssh support to the login process as well.  Once I got it going, I was so happy that I wanted immediately to email someone and tell them how I did it!

Since originally posting my solutions to the 'net and mailing the CDE FAQ maintainer, I have also created Solaris 7 packages containing fvwm2 and Vtwm, the two alternative window managers that are the most widely used in our little research group.  At the bottom of this page I'll give you the chance to download the original tar file that I posted with my message, as well as the package files.

Disclaimer: I only know two things: Jack and Crap.  And Jack left town.  Consider yourself forewarned.

Step 1: Creating the Directory Structure

You don't have to modify the original files.  CDE will automatically look for a duplicate of the /usr/dt directory tree in /etc/dt, and it will assume that /etc/dt contains any system specific modifications that you want to implement.  So the first thing you will want to do is to create the following directories in /etc/dt:

These first few directories were already installed on my Solaris 2.7 system:
 

Name User:Group ownership Permissions
/etc/dt root:root 0755 The dt directory itself
/etc/dt/appconfig root:root 0755 Application config directory

I had to create the following myself:
 

Name User:Group ownership Permissions
/etc/dt/appconfig/icons bin:bin 0755 Icon directory
/etc/dt/appconfig/icons/C bin:bin 0755 Language specific icons
/etc/dt/config root:bin 0755 CDE configuration
/etc/dt/config/C root:bin 0755 Language specific CDE configs
/etc/dt/config/C/Xresources.d root:bin 0755 CDE login config directory

Step 2: Create a pair of icons for your favorite window manager

CDE will use a different icon depending on whether the display is color or monochrome.  Use the XPM format for the color icon, and the XBM format for the monochrome file.  The default size for the built in icons is 237x237, and if your icon is larger than that, it will get cropped by CDE's login window.  (This is probably configurable, but I didn't spend the time to find out how to do it.)

When you go to save the files, CDE doesn't look for files ending in .xpm or .xbm.  So once you've created the icons, save the XPM (color) file with the ending .pm and the XBM (monochrome) file with the ending .bm.

Once you've created these files, place them in /etc/dt/appconfig/icons/C.  I called my icons FVWMlogo.pm and FVWMlogo.bm, which fits with the naming convention CDE uses for OpenWindows with OWlogo.[pb]m, which live in /usr/dt/appconfig/icons/C.  The file ownership and permissions on my icons are root:other, 0644.

Each of these files lives in /etc/dt/appconfig/C, with root:other ownership and 0644 permissions.  I only bothered creating the color version, and then used ImageMagick's convert to make the XBM versions.  (And ain't GIMP a cool program too?)  Also listed here are the icons that I created for the VTWM window manager.
 

FVWMlogo.pm FVWMlogo.bm

Step 3: Create an Xresources file for your favorite window manager

For Fvwm, I called mine Xresources.fvwm, and it lives in /etc/dt/config/C/Xresources.d.  The format of this file is very simple, and it is explained in the dtlogin man page.  (Man dtlogin and then search for "OWlogo" in the text.  It's in that general area.)  You can copy the Xresources.ow file from /usr/dt/config/C/Xresources.d as a template.  The file should have bin:bin ownership, and 0444 permissions.  Here's mine for Fvwm:
 

/etc/dt/config/C/Xresources.d/Xresources.fvwm
Dtlogin*altDtsIncrement: True
Dtlogin*altDtName:       FVWM
Dtlogin*altDtKey:        /usr/local/bin/fvwm2
Dtlogin*altDtStart:      /etc/dt/config/Xsession.fvwm
Dtlogin*altDtLogo:       FVWMlogo

Leave Dtlogin*altDtsIncrement at True.  Trust me, this makes everything flow smoothly.

Change Dtlogin*altDtName to the name of your window manager.

Dtlogin*altDtKey is the name of a file that CDE login looks for to determine whether or not that window manager is installed on that machine.  Normally it is the binary of the window manager program itself, but it could be any file that's associated with that window manager.

Dtlogin*altDtStart is the name of the script to run to begin the session.  NOTICE: If you have copied Xresources.ow from /usr/dt/... as a template, make sure to change the /usr to /etc, or you'll spend hours pulling your hair out like I did.

Dtlogin*altDtLogo is the basename of the icon file to display when this icon manager has been selected.  This is the file that we created in step 2.  Notice that the extension is not listed.

Step 4: Create the Xsession.fvwm file

I copied the OpenWindows one from /usr/dt/config/Xsession.ow and placed it in /etc/dt/config.  Then I renamed it to Xsession.fvwm.  Give it bin:bin ownership and 0555 permissions.  NOTICE: make sure you use the same filename that you placed in the Xresources file in step 3 above, or again, you'll be spending a lot of time pulling your hair out.

If you copy the OpenWindows file and edit it, there are a few things to keep in mind.  First, you want to change any references to /usr/dt/config/... to their counterpart in /etc/dt/config/...  Don't worry if the file doesn't exist yet, we haven't gotten that far.  Just trust me.  Another thing you will want to do is change the text used by the dthello program from 'Starting the OpenWindows Desktop' to 'Starting the FVWM Desktop'.  As an added bonus, if you like to use ssh, as I do, then this is where to start the ssh-agent, and I'll show you how I do it.

Here's how my file looks for FVWM.  The comment sections I added to show you what I changed.  Read 'em or suffer the same mistakes that I did:
 

/etc/dt/config/Xsession.fvwm
#!/bin/ksh

DTDSPMSG=/usr/dt/bin/dtdspmsg

if [ -z "$SESSIONTYPE" ]
then
        export SESSIONTYPE="altDt"
fi

if [ -z "$DTSTARTIMS" ]
then
        export DTSTARTIMS="False"
fi

###########################################################################
#
# I changed the following reference to point to /etc from /usr, and from
# Xsession.ow2 to Xsession.fvwm2.  No, the 2 on the end is not a typo. If you
# give CDE login the name of *this* file, it'll loop forever.  (Well, not
# forever.  Eventually it'll run out of memory and barf, as I found out. :)
#
###########################################################################

if [ -z "$SDT_ALT_SESSION" ]
then
        export SDT_ALT_SESSION="/etc/dt/config/Xsession.fvwm2"
fi

###########################################################################
#
# I changed the following text in dthello from 'OpenWindows' to 'FVWM'.
#
###########################################################################
 

if [ -z "$SDT_ALT_HELLO" ]
then
  if [ -x $DTDSPMSG ]; then
     export SDT_ALT_HELLO="/usr/dt/bin/dthello -string '`$DTDSPMSG -s 37
/usr/dt/lib/nls/msg/$LANG/dthello.cat 1 'Starting the FVWM Desktop'`' &"
  else
     export SDT_ALT_HELLO="/usr/dt/bin/dthello -string 'Starting the FVWM
Desktop' &"
  fi
fi

export SDT_NO_DSDM=""

###########################################################################
#
# Here's where I check to see if my ssh package is installed.  If it is, then I
# test to find out where it's installed (/usr on my ststem) and then set the
# SSH_AGENT variable appropriately.  You can get by with less, but the nice
# thing about this is it takes advantage of the fact that I've made ssh a
# package, and yet if said package isn't installed, it doesn't make dtlogin
# barf.
#
# You could get by with something like this:
#
#       if [ -x /...<wherever>.../bin/ssh-agent ]; then
#               SSH_AGENT=/...<wherever>.../bin/ssh-agent
#       else
#               SSH_AGENT=
#       fi
#
###########################################################################

SSH_PACHAGENAME="ssh"
/bin/pkginfo -q ${SSH_PACKAGENAME}
if [ $? -eq 0 ]; then
        SSH_BASEDIR=`/bin/pkginfo -r ssh`
        SSH_AGENT=${SSH_BASEDIR}/bin/ssh-agent
else
        SSH_AGENT=
fi

###########################################################################
#
# Start the session.  Notice that if I don't have SSH installed, then the
# SSH_AGENT variable is empty, and the following line only runs the session
# manager script by itself.  (I thought that was rather slick of me. :)
#
###########################################################################

${SSH_AGENT} /usr/dt/bin/Xsession
 

As you read this file, be careful to follow any line wraps that your browser may have put in automatically!  Some knowledge of scripting comes in handy here...

Step 5: Create the Xsession.fvwm2 file

You'll notice that in step 4 we made a reference to the script Xsession.fvwm2, which doesn't exist.  Now it's time to create it.  Again, I copied  /usr/dt/config/Xsession.ow2 and edited it.  Place the file in /etc/dt/config and give it bin:bin 0555 ownership and permissions.  NOTICE: Make sure that the filename matches up with the file referenced in step 4 above!

The number of changes that I had to make to this file are few.  Again, I changed any references from any files in /usr/dt/config to /etc/dt/config.  I also added /usr/local/bin to the PATH variable so that fvwm could find it's own files.  I also changed the echo statement from OpenWindows to FVWM. Here's what it looks like:
 
 

/etc/dt/config/Xsession.fvwm2
unset SDT_ALT_SESSION
unset SDT_ALT_HELLO
unset SDT_NO_DSDM

###########################################################################
#
# Change the DEFAULT_XINITRC file to the one that we will create for fvwm.
# Don't forget to change /usr to /etc or you'll be sorry!  I also added
# /usr/local/bin to the path so that fvwm could find itself.
#
###########################################################################

DEFAULT_XINITRC="/etc/dt/config/Xinitrc.fvwm"
HOME_XINITRC="$HOME/.xinitrc"
PATH=/usr/local/bin:/usr/dt/bin:$PATH:/usr/openwin/bin
export PATH

    if [ -z "$XINITRC" ]; then
        if [ -f $HOME_XINITRC ]; then
            XINITRC=$HOME_XINITRC
        else
            XINITRC=$DEFAULT_XINITRC
        fi
    fi

###########################################################################
#
# In my traditional anal-retentive fashion, I also changed the following echo
# statement, not that it has any outcome on the functioning of the script or
# anything.
#
###########################################################################

    echo "FVWM Desktop Login"

    if [ -f $XINITRC ]; then
        echo "using xinitrc file: $XINITRC"
        /bin/ksh $XINITRC
    else
        echo "xinitrc file: $XINITRC not found"
        if [ -f $DEFAULT_XINITRC ]; then
            echo "using xinitrc: $DEFAULT_XINITRC"
            /bin/ksh $DEFAULT_XINITRC
        fi
    fi
 

Step 6: Create the Xinitrc.fvwm

We're almost there.  Now all we have to do is create the default xinitrc file.  Again, I copied mine from /usr/dt/config/Xinitrc.ow.  Place the file in /etc/dt/config and give it the same filename that you placed in the second Xsession file from step 5 above.  Make it owned by bin:bin and give it 0444 permissions.  I butchered my file, as I didn't need most of what OpenWindows had.
 
 

/etc/dt/config/Xinitrc.fvwm
if [ -f $HOME/.Xdefaults ]; then
    xrdb -merge $HOME/.Xdefaults        # Load Users X11 resource database
fi

eval `locale_env -env`                  # Set Locale Environment

/usr/local/bin/fvwm2
 

Step 7: Testing and troubleshooting

Stick yourself on a fork, you're done!  Now all you have to do is restart the dtlogin daemon by typing:

/etc/init.d/dtlogin stop ; /etc/init.d/dtlogin start
Pat yourself on the back and go grab a rootbeer, by the time you get back, dtlogin will be back up and ready to roll!
 
(1) Test the login by, what else, logging in.  You should be able to select Options --> Session and see your window manager listed among the alternatives to CDE.  If you don't, then you need to check that /etc/dt/config/C/Xresources.d/Xresources.fvwm file is where it should be, contains what it should contain, and has the correct permissions and ownership.  Go back and check it against step 3 above.
(2) Once you've selected your alternative window manager, you should see your icon come up in the window to the right.  If it doesn't check the reference in the Xresources file and make sure that the filename matches up with the files in /etc/dt/appconfig/icons/C.  Also make sure that the extensions on the icon files are .pm for the XPM file and .bm for the XBM file.  Baring that, check the permissions to be sure that the files are readable by everyone.  See step 2 above for reference.
(3) If you get that far, and you get a login incorrect, then either you typed in your password wrong, or something is wrong with the first Xsession file.

Check that the reference listed in /etc/dt/config/C/Xresources.d/Xresources.fvwm matches the filename of the script in /etc/dt/config.  Then check that the file has the correct ownership and permissions, and check that it has the correct contents.  In my laborious debugging efforts, I found ~/.dt/errorlog and ~/.dt/startlog to be useless for detecting problems at this stage.  Instead, I added 'echo "Im here" > /tmp/log' to different files to check that they were indeed being executed.  (See step 3)

If the first Xsession file checks out, check the reference to the second Xsession file and see that it matches the pathname to the file that exists.  Also check the ownership and permissions of the second file and see that it's cochure.  I used the same echo trick as above and found that my path in the first Xsession file still pointed to /usr instead of /etc -- my second Xsession file was never being run.  (See steps 4 and 5)

(4) If the Xsession files are okay, then I start seeing useful output to ~/.dt/errorlog and ~/.dt/startlog.  Then it's just a simple matter of checking the /etc/dt/Xinitrc.fvwm file and making sure that it's found and executed.  By this stage in the game, you should have access to a function called Log that's defined in /usr/dt/bin/Xsession.  You can use that to log useful debugging statements in the Xinitrc file.  Also, if you have a file in your home area called ~/.xinitrc, then that file is run instead.  You may want to check it, too.  I checked my login using my root account, as root doesn't have any ~/.x* files.  Also, make sure that you aren't doing anything screwy in your ~/.xinitrc file that is causing a conflict with CDE's loginprocess.  (See step 6)
(5) Finally, the last thing to check is that the window manager's default configuration file can be found by the window manager program.  I finally pulled the remainder of my hair out before I realized that the reason I wasn't seeing anything useful on my screen was that fvwm couldn't find the system.fvwm2rc file.  Again, if you have rolled your own in your home area, then (a) you won't have to worry about the window manager finding the system default, and (b) you will have to worry about any conflicts that your personal file may (or may not) cause with the CDE login process.  Again, your mileage may vary.

Okay, that's it.  In little while I will have added logins for each of our system's window managers to CDE, and then I'll be sittin' fat!  (Well, in more ways than one... :)

Downloads: My software packages (NOTE: Big Time Caveat Emptor!)
fvwm-configs-original.tar.gz The original tar file posted with my original how-to instructions.
original-posting.txt The original posted message.
fvwm-2.2.2-sol7-sparc-local.gz My fvwm binary install package.  It installs fvwm in /usr/local by default.  Familiarity with pkgadd is assumed.  (Never the less, see below for instructions on how to install it.)
fvwm-config-2.2.2-sol7-sparc-root.gz My fvwm CDE configuration package.  It requires the fvwm package above as a dependancy.  It installs in /.  The postinstall script will check for the base install directory of fvwm, so if you don't install fvwm in /usr/local, postinstall should be able to figure that out on it's own and make the necessary changes to the configuration files.  (This has never been tested, of course.)  On my system, /usr/local is mounted via nfs from a local file server.  Because of this, if postinstall doesn't find fvwm in the package database, it assumes that it's in /usr/local and goes ahead with the installation.  This works great for me, but pay attemtion or it may cause you a big headache.
vtwm-5.3-sol7-sparc-local.gz My vtwm binary package.
vtwm-config-5.3-sol7-sparc-root.gz My vtwm CDE configuration package.

 
Solaris Packaging System: Playing with packages - pkgadd and pkginfo

Solaris uses a package management system for installing, removing, checking and maintenance of software installed on the system.  You can also use the package management programs to install and even disect the packages that I have above. I'll assume that you know nothing about it and proceed from there.  (That's usually the only safe assumption that I have ever been able to make!)
 
 
(1) Download the packages: In Netscape, hold down the shift key and click on the file you'd like to download.  Since this is about installing CDE logins, I'll use fvwm-config-2.2.2-sol7-sparc-root.gz as my example.
(2) Uncompress the file: gunzip fvwm-config-2.2.2-sol7-sparc-root.gz
This will create the file fvwm-config-2.2.2-sol7-sparc-root.  This is what Solaris calls a package spool file.
(3) As with any package, you will need to know the package name before you can install it.  The package name may not be the same as the spool file's filename.  (Like SUNWaccu, how do you know what that is?)  This is because you are restricted to only 9 characters for a package name.  To find out the name of the package in a spool file, type the following:
pkginfo -d ./fvwm-config-2.2.2-sol7-sparc-root
You will see output like this:
application fvwmcfg        fvwm-config
The part you're interested in is the second field: fvwmcfg.
(4) To install the package, type the following:
pkgadd -d ./fvwm-config-2.2.2-sol7-sparc-root fvwmcfg
This tells Solaris to install the package fvwmcfg which lives inside the spool file fvwm-config-2.2.2-sol7-sparc-root.
(5) If you want to take a look at the package's contents and see the files that I've used, type:
pkgadd -s . -d ./fvwm-config-2.2.2-sol7-sparc-root fvwmcfg
This tells Solaris that you want to install the contents of the spool file -- i.e. un-spool it -- into the directory ./

Once this command has completed, you 'll have a directory called ./fvwmcfg, in which lives the package.  Inside you'll find the following directory structure:
 
./fvwmcfg/pkginfo (package information file)
./fvwmcfg/pkgmap (package manifest, contains a list of all the files in the package and the file's ownership/permissions)
./fvwmcfg/install/ (package install/uninstall scripts)
./fvwmcfg/reloc/ (files to install -- this is where the good stuff is)

Of all this mess, the stuff to look at is in ./fvwmcfg/reloc/ and the file ./fvwmcfg/install/postinstall.

NOTE: You cannot simply copy these files into place!

This is for your edification only, for those who want to see how I made the package.  These files contain strings like "@FVWM_BASEDIR@", which are nonsense strings.  They are processed by the postinstall script which replaces these strings with the directory names of where the programs live.  Specifically, on my system, "@FVWM_BASEDIR@" becomes /usr/local.  There are other strings which are processed in a similar fashion, namely "@SSH_BASEDIR@", "@PKG_INSTALL_ROOT@", and "@CLIENT_BASEDIR@".  If this isn't apparent, then take a close look at ./fvwmcfg/install/postinstall.  You'll see a for loop with a call to /bin/sed in it.  This is where these strings are being processed.

(You can ignore the SSH_BASEDIR reference and the scripts should work just fine.; "@SSH_BASEDIR@" will be replaced with an empty string, "".)

For more information on Solaris packaging, take a look at Creating pkgadd Software Packages at sunfreeware.com, and the Application Packaging Developer's Guide at docs.sun.com.

Take care, God bless, and don't let the Y2K bug bit28@#&*^

NO CARRIER