Troubleshooters.Com®, Linux Library and Steve's ctwm Secret Stash Present:

Installing ctwm

Contents:

Introduction

All other things being equal, the best way to install ctwm is via your Linux or BSD distribution's package manager. This document assumes you know how to do that.

But sometimes a distro's ctwm is old or broken. For instance, Debian Stretch still offers version 3.7-4, which debuted at least ten years ago. The current version as of today (9/30/2017) 4.0.1, which debuted 6/5/2017. In such cases it's better to compile it yourself. This document tells how.

Downloading and Extracting the Code

  1. mkdir ~/compile
  2. cd ~/compile
  3. Browse to https://www.ctwm.org/download.html
  4. Download either ctwm-4.0.1.tar.xz or ctwm-4.0.1.tar.gz.
  5. tar xJf ctwm-4.0.1.tar.xz if you downloaded the tar.xz format, or...
  6. tar xzf ctwm-4.0.1.tar.gz if you downloaded the tar.gz format
  7. Notice now that you have a nice source code tree whose root is ~/compile/ctwm-4.0.1. You've successfully downloaded and extracted the ctwm source code.

The Dao of Hand-Compiling

The section after this one asks you to hand-compile ctwm, meaning to compile all the source code instead of having a package manager install it for you. Some folks consider hand-compiling to be beyond their capabilities, and for a few, that's true. But for most of us, hand-compilation is within reach: We just need to adopt the right set of beliefs and habits to make it happen. Obviously belief #1 is that you can do it: Folks believing they can't do something don't try hard enough or long enough to succeed. Another belief is the belief that even non-programmers can hand-compile. Don't get me wrong, being a programmer helps, but a non-programmer can follow instructions and read error messages well enough to hand-compile.

There are more beliefs and habits for efficient hand-compilation, all of which are discussed in this section. But before discussing the beliefs and habits necessary to hand-compile, let's discuss what a package manager normally gives you, because what the package manager normally gives you is what you're going to have to simulate manually during hand-compilation...

How Package Managers Work

Hand-compiling source directly from the software's author, without a package manager, comes with some extra challenges best understood by considering what your distro's packaging system does for you. The person responsible for a package figures out what other distro packages are necessary for the software to compile and run. These necessary package are called "dependencies." That responsible person knows the exact name given these packages in the distro --- no need to guess. This list of dependencies, with its correct names, is included in the package file.

So when a user installs a package: Let's say the ctwm package, the package manager software makes a dependency tree by going through all of ctwm's dependencies, and finding their dependencies, and then finding the dependencies of those dependencies, deeper and deeper until a given sub-dependency has no uninstalled dependencies. In Node Theory, such a subdependency is called a "leaf node." The descending construction of the tree continues until every path down the tree is terminated by a leaf node.

The package manager software's next step is to install all the leaf nodes, which go in cleanly because they have no uninstalled dependencies. The installation of those leaf nodes is bound to eliminate the uninstalled dependencies of some other nodes, which then become leaf nodes and are installed, creating more leaf nodes, up and up until finally the asked-for package is installed.

As a user, your hands remained pretty clean during this operation. You didn't need to find dependencies and subdependencies. You weren't challenged to find the right names for each dependency and subdependency. You didn't need to decide the order in which to install the dependencies and subdependencies. At worst you got asked a couple questions about additional features, and then BANG, your software was installed.

Your responsibility during hand-compilation

During hand-compilation, you won't receive help on:

  1. Finding dependencies and subdependencies
  2. Find the right names for each dependency and subdependency
  3. Figure out the order in which to install the dependencies and subdependencies

You'll be doing the preceding tasks yourself, and that can be a challenge requiring calm, clear thought and adherence to a simple process. The process is shown in the following flowchart:

Flowchart of compilation process

Obviously, adherence to the preceding flowchart requires discipline and belief in process. Beyond that, two steps require real discipline and thought:

Carefully read error message

Most people fall down on the job at this step. They see an error message and say to themselves "Oh s#^($t, it failed, what now? I'll never be able to get this thing done! Might as well not even try.

And the sad part is, they never really read the error message. They don't realize that the error message isn't a flunking grade: It's a hint as to what to do next. With well built code sets like ctwm, it's most likely telling you about another uninstalled dependency.

So what you're going to do that most people don't is read the error message. Not just the last line, but the last 20 lines. Instead of prioritizing the lines that basically say "you failed", you're going to prioritize the lines saying something like "can't find whatever" or "missing whatever" or "file not found: whatever". You're going to carefully read every line and ask yourself this one question:

What is it telling me is missing?

By calmly viewing error messages as hints as to how to get it right, instead of as negative feedback, you'll place yourself at the front of the pack, whether you have 20 years of C programming experience or you've never programmed a day in your life.

Best guess next package and notate

The error message has told you, in the compilation processes own words, what's missing. If you're dealing with fully formed, high quality software like ctwm, and you're dealing with a fully formed, quality Linux distro, this error message can probably be solved by installing a package with the package manager. The question is, what's the name of the package?

For instance, if the compiler told you it can't find your "XPM library", you might run the following command:

apt-cache search xpm

A whole bunch of stuff is returned, the most relevant of which are:

So install libxpm4. Probably it will say it's already installed, but if it doesn't, go another round on the flowchart. If it is already installed, try libxpm-dev. What's very typical on these dependencies is they need the .h files, and on various distros those are usually bestowed by packages ending in "dev" or "devel". Samewise, if the error message gripes about a missing .h file, you probably need to install something ending in "dev" or "devel".

Because the message talked about "XPM library", you'll prioritize those starting with "lib" over the xpmutils, which are probably a bunch of little programs to interact with the XPM library.

Learn your package manager's search vocabulary, because you're going to be using it a lot.

To summarize this section, whether you've been a C programmer for 20 years or never written a program in your life, you'll be able to efficiently hand-compile programs if you adopt the following beliefs:

Compiling ctwm

  1. Locate and skim-read ~/compile/ctwm-4.0.1/README.md. You'll be using this document as your guide.
  2. Notice that README.md says you'll need to install the following packages:
    • libX11
    • libXext
    • libXmu
    • libXt
    • libSM
    • libICE
    • libXpm
    • libjpeg
  3. In the preceding list, observe the following:
    • These are guesses at the package names: The exact package names are distro dependent.
    • Depending on what's already been installed, you might need only the -dev or -devel package for some, or maybe no package at all if both were already installed.
    • The last two on the list are optional, there might be other optional packages that need installing depending on your compile time choices, and it might compile initially without these choice packages, only to crash later when features needing them are used.
  4. Install cmake
  5. cd ~/compile/ctwm-4.0.1
  6. make
  7. When the compile errors out, use the error messages to guide you in what package to install next. Also use the list of packages included in README.md, but remember, the package's exact name is distro dependent and finding it requires using your package manager's search facility.
  8. Install the (hopefully) needed package, and record it in a list.
  9. Go back to step 6
    • Repeat until fully compiled
  10. Last but not least, perform the following two commands:
    mv ~/.ctwmrc ~/ctwmrc.org
    cp ~/compile/ctwm-4.0.1/system.ctwmrc  ~/.ctwmrc
    

Specifying ctwm As Your WMDE

WMDE stands for Window Manager or Desktop Environment. Any software that could be called either of those terms is a WMDE. There are two ways to specify ctwm as your WMDE. Which one you use depends on whether you boot straight to GUI, or whether you boot first to CLI (Command Line Interface) and then run startx to bring up your GUI.

Running startx from CLI

If you boot to CLI and then run startx to get your GUI, you specify ctwm as your WMDE of choice in the ~/.xinitrc file. An unadorned setup should use a file resembling the following:

#!/bin/sh
xrdb -load $HOME/.Xdefaults
exec $HOME/compile/ctwm-4.0.1/build/ctwm

The xrdb line is necessary only if you're using .Xdefaults to change elements of your GUI appearance.

Booting to GUI

I don't normally boot to GUI, so this subsection is tech-edited on a Devuan Jessie virtual machine guest, using the slim Desktop Manager. A Desktop Manager is the GUI thing that allows you to log in, and also gives you a choice of various WMDEs.

The first step is to get the Desktop Manager to recognize that ctwm is a WMDE choice. You do that by making sure that ctwm has a desktop file. In Devuan Jessie, the desktop file ctwm.desktop resides in the /etc/dm/Sessions directory, and looks like the following:

## /etc/dm/Sessions/ctwm.desktop ##

[Desktop Entry]
Name=ctwm
Comment=ctwm
Exec=$HOME/compile/ctwm-4.0.1/build/ctwm
TryExec=$HOME/compile/ctwm-4.0.1/build/ctwm
Terminal=True
Type=Application

If this file is there, the Desktop Manager should be able to find it and give it to the user as an alternative. If not, put it there.

NOTE:

Computers have many *.desktop files: Only a few are used to guide the Desktop Manager. Their location varies from distro to distro. In Devuan Jessie, they're in /etc/dm/Sessions. In Void Linux, they're in /usr/share/xsessions.

Once you've done the preceding, get into the Desktop Manager either by logging out of your current WMDE, or booting the computer. Now enter your username, then select your desired WMDE (ctwm), and enter your password. You should go into ctwm. Please note that most Desktop Managers do all of this in counterintuitive ways, so you might have to experiment or ask a more knowledgeable friend. Which is one of the many reasons I boot to the command line and then get to GUI by running the startx command.

Testing ctwm

At this point, you should have a very crude, not especially useful, but working ctwm available for running. You compiled it, you copied a rudimentary config file to ~/.ctwmrc, and you saw to it that either your Desktop Manager (the GUI login thing) can find ctwm, or that the startx command always runs ctwm via the ~/.xinitrc file. It should work.

So now, log out of whatever WMDE you were using, and either run startx or use your Desktop Manager to change WMDEs to ctwm, and then log in again. Either way, you should be greeted by a screen you can left click on to pull up a menu. If the menu's title says something about either "Twm" or "ctwm", you've done it. If you don't see such a menu title, either you've failed to run ctwm, or your ctwm has a different menu title. In general, you can prove or disprove whether it's really ctwm by making a change in ~/.ctwmrc, using the menu to restart ctwm, and seeing whether your change took effect. An excellent change would be to change the 3 digit number inside the menu font from its typical 120 to a huge number like 400. If the menu printing changes to a size you'd expect to see on a clock face, you've proven you're in ctwm. Be sure to change it back to 120, or if you'd like something bigger or smaller, set it accordingly. I set my menu font at 200.

DANGER!

Don't attempt to do any real work in this bare bones ctwm. Don't in any way evaluate ctwm based on this bare bones ctwm. The system.ctwmrc that ships with the software is useable only by folks who have been using ctwm, in more or less its default state, for years. The default setup has no way to close windows not closeable from their own command lines or menus. The only way to run an arbitrary program with the default setup is to run an Xterm and then run the program from the Xterm's command line (remember to put the & on the end). People accustomed to modern WMDEs will find the default setup's window focus system to be an intermittent mess. DO NOT evaluate ctwm based on the default setup.

The other documents in Steve's ctwm Secret Stash are devoted to helping you make ctwm into the WMDE of your dreams, whatever those dreams may be.


[ Training | Troubleshooters.Com | Email Steve Litt ]