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

Modernizing ctwm

Contents:

Introduction

Ctwm is a spectacular WMDE (Window Manager or Desktop Environment), and it's based on the very old twm WMDE that came out in 1987. Twm was created as a window manager for X Windows systems on minicomputers and super-workstations such as the VAX or the various Sun minicomputers and workstations. Users of these expensive and powerful machines typically thought of a graphical user interface as an afterthought, often using graphics just to position multiple terminals on one screen or to perform an inherently graphical task such as image layout and video creation. They didn't need a lot of open windows, so they didn't need the window manager to enable an efficient workflow. Typical GUI useage back in those days involved little or no overlap, so dragging windows to move and size them was practical. Except for the Macintosh, no consumer computer of that era gave a coherent and powerful graphical user interace.

In 1992 Claude Lecommandeur added multiple workspaces to the twm source code, creating ctwm" Although by 1992 Microsoft Windows 3.x had given the population greater expectations of a graphical user interface GUI, most people didn't expect much from their GUI, so ctwm was more than sufficient. For some perspective, consider that the first Linux kernel was created in 1991, the SLS distribution 1992, the Yggdrasil distribution in December 1992, and the Slackware distribution in 1993. SuSE and Redhat, the first widely used distribution, came out in early and late 1994, respectively. In other words, ctwm predates any widespread Linux usage, and for its time it was very sufficient.

By 1999, ctwm, as typically configured, didn't live up to the expectation of the huge number of GUI users of Windows, Mac, and GNU/Linux. Instead of a window "having focus" meaning both on top and receiving keystrokes, standard ctwm often has one window on top and another receiving keystrokes. Or no window receiving keystrokes. Ctwm's "focused" window typically depended on the location of the mouse pointer: A real departure from expectations for anyone raised on Mac, Windows, KDE, or even the early Gnome that existed in 1999. Although some radical Linux users love mousepointer-defined focus, most 21st century computer users would curse at the unusual and hard to predict behavior of a typical ctwm setup.

Which is a shame, because ctwm is highly configurable and can be configured to behave pretty much like a modern user would expect. The purpose of this document is to guide the new ctwm user through the configuration changes enabling usage by a modern user, without detailed study of the ctwm man page and a lot of practice.

This Document Describes Ctwm 4.0.1

This document is meant to be used with a hand-compilation of the ctwm 4.0.1 tarball. It will probably be useful in other situations, such as ctwm provided by distribution packages, but it's tech edited only for hand compiled 4.0.1.

Virtual Machine Guests Make Things Easier

One of the problems with experimenting with a WMDE is that an inefficient setup can leave your computer almost unusable. One way around that is to run a Linux OS, with a ctwm WMDE, in a Virtual Machine Guest. I use Qemu: Virtualbox is also good, especially if you're using a Windows computer to host the VM. If you're on a Mac, you can run Linux under the Parallels system.

If you're not going to use a VM, don't start up ctwm until you've performed all the tasks in the whatever section of this document.

Compilation Standard For This Document

This document assumes your ctwm 4.0.1 tarball unarchives to the ~/compile/ctwm-4.0.1 tree, the ctwm you'll be running is at ~/compile/ctwm-4.0.1/build/ctwm, and the man page, which you'll be looking at via a text editor, is an Asciidoctor file at ~/compile/ctwm-4.0.1/build/doc/manual/ctwm.1.adoc. This way, whenever you recompile your ctwm, your changes will be reflected in ctwm after you stop it and start it.

If you later decide to use make install, you can change the locations as necessary.

Beware of Surprising Menu Behavior

Ctwm menus are difficult or impossible to learn until you know a small, trivial secret, and then they're easy as pie.

Restarting ctwm

The person who closes ctwm, re-logs in, then re-opens all necessary windows just to view the result of a config file change, will soon give up in frustration. Ctwm has a function, called f.restart, that rereads ~/.ctwmrc and restarts according to that file's configuration. It leaves all windows up, and neither terminates your X session nor makes you log in again. It's a huge timesaver: A necessary timesaver.

Most ctwm setups have this setup available from the menu: Click the main menu's Exit choice, slide right, then click "No, restart ctwm." If your menu doesn't have an obvious way to restart ctwm, then you can create a keyboard hotkey as follows:

"F9" = m | c | s : all : f.restart

Put the preceding hotkey def with the other hotkey defs in ~/.ctwmrc, or if there are none, put it right below the mouse button command definitions.

You probably noticed that this hotkey involves Alt, Shift and Ctrl. That's because you don't want this hotkey to be easy to hit. It's for emergencies only, when your menu can't restart ctwm.

As long as you're at it, you might as well add a hotkey to terminate ctwm. Here it is, mapped to Ctrl+Shift+Alt+F8:

"F8" = m | c | s : all : f.quit

Put it right below the hotkey that restarts ctwm, and as mentioned before, use it only for emergencies: Quitting your graphical user interface deserves the time and attention of a mouse process.

Specifying ctwm As Your 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.

Running Programs

Unlike more sophisticated WMDEs, ctwm isn't aware of what software has been installed. Package managers don't try to make a menu item for themselves in ctwm. The ctwm main menu (the menu that runs when you click the desktop) is typically useful only for Exit, Restart, and a terminal, probably xterm. Make sure whatever that terminal is, it's installed with fonts you can read. If you greatly prefer a different terminal, add it to the "windowops" menu of ~/.ctwmrc.

Then, to run any given GUI program, run it in the terminal and append a space and ampersand (&) to the command. If this becomes a pain, you can either add submenus to ctwm's menu system, or do what I do, incorporate dmenu into ctwm. But at this point it's too soon to incorporate dmenu: Ctwm at this point is too ornary. Save dmenu incorporation until you've at least finished this document's Gross Modernization section, later in this document.

Gross Modernization

Very few people use ctwm because its behavior and interface are so different from the majority of modern WMDEs. The few who use it love it the way it ships, but its as-ships behavior would drive most modern people to give it three minutes and quit in frustration. This sections gives you some quick alterations to make ctwm moderately useful to the average modern person, and especially tames the antique focusing behaviors.

Add the following lines to your ~/.ctwmrc, just below the font declarations and the various one-word declarations:

######## BEGIN STEVE LITT'S MODERNIZATTION SETTINGS #########
ClickToFocus            # Prevent mouse movement changing focus
RaiseOnClick            # Window rises when clicked
RaiseOnClickButton 1    # When clicked with button 1, that is.
UsePPosition "on"       # Help kbd instantiated windows get focus
RandomPlacement "on"    # Help kbd instantiated windows get focus
AutoFocusToTransients   # Help kbd instantiated windows get focus
SaveWorkspaceFocus      # Obviously workspace focus should be retained
WindowRing              # Enable Alt+Tab type window circulation
WarpRingOnScreen        # Enable Alt+Tab type window circulation
IgnoreCaseInMenuSelection # Make menus much easier via keyboard
ShortAllWindowsMenus    # Don't show iconmgr and workspace mgr in lists

TitleButtonBorderWidth 2 # Put space between titlebar buttons
LeftTitleButton ":menu" = f.menu "windowops" # Window menu button
RightTitleButton ":xlogo" = f.delete         # Window close button
########  END  STEVE LITT'S MODERNIZATION SETTINGS #########	

Speaking of the window menu, add the following two lines to the windowops menu, right below its title:

    "Raise"		f.function "focus-raise"     #slitt
    ""			f.separator                  #slitt

The preceding gives you the ability to raise a window from the window menu, but don't test it yet, because you didn't write the focus-raise function yet. Instead, your next move is to put the following code right after the separator that follows the "Info" choice on the menu:

    "Maximize toggle"   f.fullzoom                 #slitt
    "Fullscreen"        f.fullscreenzoom           #slitt
    ""                  f.separator                #slitt

The preceding lines, combined with the "Resize" and "Move" choices, gives you control over the size of the window. Basically, choosing "Maximize toggle" toggles the window's maximization. The "Fullscreen" invokes fullscreen (remove window decorations and maximize the remainder). To come back from fullscreen, move the window down and to the left, then resize it smaller. To move it down and to the left, you must have a "move" mouse action whose context is the window's client area, not the titlebar. Here's an example:

Button1 = m	: window|icon	: f.function "move-or-lower"

Now it's time to code the focus-raise function. Below the other functions in ~/.ctwmrc, code the following:

Function "focus-raise" {f.focus f.raise}               #slitt

You've completed the gross modernization of ctwm. At this point, if you use your mouse for all windowing activities, and constrain your activities to one workspace, your user interface should seem logical and familiar, with few surprises.

Accommodating Workspaces

The preceding article had you working perfectly on one workspace. Of course, the whole point of ctwm was that it added workspaces to the 1987 twm, so workspaces are a must. This section gives you the bare essentials of workspace travel you need in order to operate across several workspaces. Everything in this section is mouse driven. Other parts of Steve's ctwm Secret Stash will clue you in to more efficient workspace travel.

There are two ways to navigate workspaces: Brute force menus, and the super-magic workspace thingy, which looks like 8 chicklets in 2 rows of 4 columns each. This section uses a little of each.

To start with, give yourself a way to navigate from workspace to workspace. Insert these two lines just above the line saying:

"Left"  = c | m : all : f.leftworkspace
"Right" = c | m : all : f.rightworkspace

So Ctrl+Alt+Left moves one workspace higher, and Ctrl+Alt+Right moves one lower.

The super-magic Workspace Manager thingy can be quite helpful if used right:

Here are the changes, inserted just above the "#### END STEVE LITT'S KBD ENHANCEMENT SETTINGS ####" LINE, to accommodate the preceding behavior:

OnTopPriority 8 { "WorkSpaceManager" }
OnTopPriority Icons 8 { "WorkSpaceManager" }

NOTE:

Depending on your visual acuity, you might want to change the font of the Workspace Manager. To do so, simply add or change a font called WorkSpaceFont. I'd recommend you start with 12 point, and then go up or down according to your eyes.

Using the workspace manager thingy maximized, you can move windows from workspace to workspace, without moving to workspaces yourself. You can also click on a workspace to "go there." The Workspace Manager currently has no glanceable way to deduce what workspace you're currently on.

The way I use the workspace manager is to take it out of the "NoTitle" group: I want the workspace manager fully adorned so I can quickly maximize or iconize it. I try to keep it maximized so I can move windows around with it. When it's not being used, I iconize it and keep its upper right corner in the lower left corner of the screen, so it's easily clickable but doesn't get in the way. I make sure the Workspace Manager is always on top (level 8) whether iconized or not. Having to dig for it eliminates its productivity advantages.

When the Workspace Manager isn't available, I can move a window to another workspace by clicking "Occupy" on its menu, which pops up a special Workspace Manager window with buttons labeled "OK", "Cancel" and "All". I just click the workspace and click OK, then from the window menu I click "Vanish", and then if I want to go to that workspace I can get there with keyboard shortcuts. As you can imagine, this procedure is insanely underproductive, but at least it's possible.

Where To Go From Here

Once you've completed everything listed on this document, ctwm will be fairly intuitive, and as productive as your average untweaked WMDE. Any frustration you felt operating ctwm with the factory-default ~/.ctwmrc will be gone.

But nobody aspires merely to "as good as" or "not frustrating". This document has merely brought you to the point where you can continue to use ctwm while improving it and then finally setting it up to your personal specifications.

So congratulate yourself, go back to Steve's ctwm Secret Stash, and continue to energize ctwm's productive potential. I think incorporating dmenu would be a good next step, but I'll leave that to you.


[ Training | Troubleshooters.Com | Email Steve Litt ]