# Guide to X11/Window Managers/ctwm

Type: stacking Language: C License: GPL

## Claude's Tabbed Window Manager

CTWM is a Fork of TWM to allow multiple desktops and is a customizable, lightweight and minimal, re-parenting window manager in use on a variety of both older and newer UNIX (and derivative) operating systems. Currently it is not ICCCM or EWMH complaint but does have some GNOME support (there is a fork called ETWM that claims to be ICCCM 2.0 and NetWM/EWMH complaint in development).

## History of Development

The origin of CTWM starts in 1987 when Tom LeStrange wrote Tom's window manager. In 1989 TWM was adopted by the X Consortium as the standard window manager of X11 and re-named Tab Window Manager. Claude Lecommandeur <Claude.Lecommandeur@Epfl.Ch> added multiple workspaces to TWM after being inspired by vuewm, HP's MWM-based window manager which offers configurable workspaces, and released it in 1992 as CTWM. In 2003, when Claude stopped development, the project was continued by Richard Levitte <levitte@lp.se>. After 2014 Matthew Fuller <fullermd@over-yonder.net> took over the project. As of this writing (mid 2017) he is the current maintainer.

## Features

Features of the CTWM window manager include:
* Stacking windows
* Support for multiple desktops
* Written in C
* Auto-raise or click-to-focus modes
* Support for M4 for user-defined macros
* Support for XToolkit clients (uses XLib and XResources)
* Window decorations (including borders and a titlebar with configurable titlebuttons)
* "Shaped" windows
* Support pop-up menus by titlebuttons, pointer(mouse) buttons or keyboard
* support for icon management
* Support for themes and customized colors
* Support for desktop wallpaper
* Support for XPM, JPEG and IMCONV'd images
* Support for GNOME
* Support for sound
* Open-source and freely available on many platforms

## Using CTWM

CTWM is a traditional X window manager, unlike modern X "Desktops", Microsoft Windows or Mac OS/X. There are no graphical "Settings" managers. Starting CTWM and customizing your environment is done by the user's session manager or by editing your X configuration files, i.e. ~/.xinitrc, ~/.xprofile, etc. with a normal text-editor. The following operations are the normal compiled defaults, your SysAdmin may have configured the defaults differently or compiled CTWM without some functions, YMMV.

### Setting Up Your X-Windows Environment

Your ~/.xinitrc file is a shell script read by xinit and by its front-end startx. The xinit program starts the X Window System server and works as first client program on systems that are not using a display manager. It is used to start daemons (backgrounded apps), set the environment, and execute window managers and other programs when starting X. Your SysAdmin may have put an .xinitrc file in your home directory with some default startup apps and a default window manager or desktop environment. Open it up in a text editor (try nano .xinitrc) and scroll down to the bottom of the file. You should change the default Window Manager (usually twm) to ctwm and make any additional changes you want before saving the file.

### Window Operations

In the default configuration of CTWM, which may be found in /usr/lib/X11/[c]twm/system.ctwmrc the titlebar has two buttons:
* Right "Resize" button (nested squares): the user drags the mouse pointer to the edge to be moved, then releases when the window is the desired size.
* Left "Iconify" button (dot): iconifies the window. Click on the icon to restore it.
A left click on the titlebar, or highlighted area, raises the window to the top of the window stack; holding down the button and dragging the outline to a new location on the screen, then releasing the button, moves the window there.
A left click on the desktop brings up a menu of default operations (XToolkit apps).
* "Xterm" A "terminal" you can use to launch programs or access remote computers with.
* "Calculator" A Calculator
* "Xman" A manual browser for documentation on available programs.
* "Xmag" A screen magnifier.
* "Restart" Restarts CTWM, re-loading the .ctwmrc file. (use after editing your ~/.ctwmrc file)
* "Exit" Quits CTWM (and shuts down X-Windows).
A right click on the desktop brings up a menu of window operations. You select the operation and then left-click on the window you want to effect.
* "Occupy" Allows you to choose which workspaces a window occupies..
* "Occupy All" Copies the window to all "WorkSpaces"
* "Iconify" Iconifies/De-Iconifies the window.
* "Refresh" Refreshes the screen if "artifacts" clutter it.
* "Vanish" Removes a window from the current workspace if it occupies any other.
* "Info" Gets X-Windows information on the window.
* "Resize" Click and drag the mouse pointer to the edge of the window to be moved, then releases when the window is the desired size.
* "Move" Outlines and moves the window on the screen.
* "Adopt Window" (see the "man" page)
* "Animate" Re-start animation (if any)
* "Don't animate" Stop animation (if any).
* "Send Delete" Closes the window.
* "Kill Window" Last resort to close the window (for mis-behaved programs).
* "Pin menu" Lets the menu stay up on-screen.
There are no docks, trays or menu bars but these can be added if you start a standalone composite manager (like Compton).

### Managing Icons
## Configuring CTWM

Configuration of CTWM is done by editing the ~/.ctwmrc file with a normal text editor. If you have a /twmrc file it will use that. Take a look at Dan Lilliehorn's somewhat famed "Complete & Commented .ctwmrc" on ctwm.org (note: not updated since approx. version 3.6). There are two major types of "Feel" (from "Look-and-Feel") for window managers: "Focus-follows-mouse" (sometimes called "Auto-Raise"); or "Click-to-focus". CTWM can do both. There are three major sections to the config file: Variables; Bindings; and Menus. We'll look at Menus last after we discuss Window Decorations.

### Auto-Raise
#### Variables

This is a typical Auto-Raise Variables section, YMMV.

#### Bindings

This is a typical Auto-Raise Bindings section, YMMV.

### Click-to-Focus
#### Variables

This is a typical Click-to-Focus Variables section, YMMV.

#### Bindings

This is a typical Click-to-Focus Bindings section, YMMV.

### Window Decorations

There are many options for the User Interface style: OPEN LOOK, using a single-button on the titlebar as used by early SUNview; ICE which is a Traditional UNIX look with two buttons as used by TWM; The Motif three-button style as used by MWM and described in the Motif Style Guide; and the so-called "Clean" four-button style of modern X window managers and X Desktop Environments like Gnome and KDE.

##### OPEN LOOK

Open Look used a single titlebutton on the left which iconified the window. Clicking button 1 (normally the left mouse button) on the titlebar raised the window to the top of the window stack; button 2 (the middle button) moved the window; and button 3 (normally the right button) brought up a menu (usually of operations to be performed on the window).

##### ICE

In the default ICE configuration the title bar has two buttons:
* Right "Resize" button (f.resize): the user drags the mouse pointer to the edge to be moved, then releases when the window is the desired size.
* Left "Iconify" button (f.iconify): iconifies the window.
A left click on the titlebar raises the window to the top of the window stack; a middle click moves the window; a right click sends the window to the bottom of the window stack.

##### MOTIF

Motif uses three buttons:
* Right-most "Maximize" button (f.fullzoom): resizes the window to the full size of the display.
* Right inner "Minimize" button (f.iconify): iconifies the window.
* Left "Menu" button (f.menu "name_of_menu"): usually a menu of operations that can be performed on the window.
Also, a left click on the titlebar or highlighted area (f.move), dragging to a new location on the screen, and then releasing moves the window to that location.

##### CLEAN

* Right-most "Close" button (f.delete or f.destroy or f.deletedestroy): closes the window.
* Right middle "Maximize/Restore" button (f.fullzoom): resizes the window to the full size of the display.
* Right inner "Minimize" button (f.iconify): iconifies the window.
* Left "Menu" button (f.menu "name_of_menu"): usually a menu of operations that can be performed on the window.
Also, a left click on the titlebar or highlighted area (f.move), dragging to a new location on the screen, and then releasing moves the window to that location.