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  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 . After 2014 Matthew Fuller  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 ) 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).

There are no docks, trays or menu bars but these can be added if you start a standalone composite manager (like Compton).
 * "Pin menu" Lets the menu stay up on-screen.

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.

Variables
This is a typical Auto-Raise Variables section, YMMV.
 * 1) GENERAL CTWM CONFIG

NoGrabServer
 * 1) Don't grab server when popupping up menus and moving opaque windows

UsePPosition "non-zero"
 * 1) Respect program-requested positions: "on", "off" or "non-zero"


 * 1) Don't use the default titlebuttons and bindings
 * 2) NoDefaults

RandomPlacement "on"
 * 1) Place windows in a pseudo-random location: "on", "off", "all", "unmapped"

RestartPreviousState
 * 1) Remember if window was iconified when restarting window manager


 * 1) Raise window when one click on it
 * 2) RaiseOnClick


 * 1) Use Button 1 to raise a window
 * 2) RaiseOnClickButton 1

AutoRaise
 * 1) Automticcally raise window when cursor enters the window

RaiseDelay 250
 * 1) if Autoraise, wait N ms before raising it

AutoFocusToTransients
 * 1) Transient windows get focus automatically when created

TransientOnTop 50
 * 1)  Transient window on top if n% smaller than parent window


 * 1) Don't send key events from the titlebar
 * 2) and icon managers to the application
 * 3) NoTitleFocus


 * 1)  Use sloppy Focus
 * 2) SloppyFocus


 * 1) Don't use pointer-driven keyboard focus, but click to focus
 * 2) ClickToFocus

AutoRelativeResize
 * 1)  Don't wait for the cursor to cross an edge to resize the window


 * 1) Don't move windows Off the screen
 * 2) DontMoveOff

ReallyMoveInWorkspaceManager
 * 1) Moving the small window in the WorkspaceManager will move the actual window

StayUpMenus
 * 1)  Keep menus up if the cursor has not yet been entered by the pointer


 * 1) WINDOWS RING

WindowRing { }
 * 1)        "AppsClassName"

WarpRingOnScreen
 * 1) f.wrapring warps only to windows visible in the current space

NoRaiseOnWarp
 * 1) Don't raise windows when pointer is wraped to them

WarpUnmapped
 * 1) Deiconify any iconified windows it encounters.

Bindings
This is a typical Auto-Raise Bindings section, YMMV.
 * 1) Key bindings

IgnoreModifier { lock m2 }
 * 1) Ignore caps lock (lock) and num lock (m2) modifiers

"Up"   =  c s	  : window : f.raise "Down" =  c s 	  : window : f.lower
 * 1) Raise/lower windows with C-S-Up/Down


 * 1) You can use your favorite keys to go directly
 * 2) the preferred apps
 * 3) "F5" =  : all : f.warpto "emacs"
 * 4) "F6" =  : all : f.warpto "Mozilla-bin"
 * 5) "F7" =  : all : f.warpto "bitchx"

"Tab" = m : window : f.warpring "next" "Tab" = c : window : f.warpring "prev"
 * 1) Use the windowring using M-Tab/C-Tab
 * 2)  (you must define apps that go in the windowring, see WindowRing above)


 * 1) Workspaces and screens

"Up" = m4   : all : f.prevworkspace "Down" = m4   : all : f.nextworkspace
 * 1) Win+Up   : change workspace
 * 1) Win+Down : change workspace

"Left" = m4 : all : f.warptoscreen "back" "Right" = m4 : all : f.warptoscreen "next"
 * 1) Win+Right/Left: change screen


 * 1)  Windows placement

"Escape"       = c     : window        : f.iconify "Escape"       = m4    : iconmgr       : f.deiconify "Return"       =       : iconmgr       : f.deiconify
 * 1) Iconify window with Ctrl+Esc, Deiconify with Win+Esc

"Left" = c m4    : window : f.pack "left" "Right" = c m4   : window : f.pack "right" "Up"   = c m4    : window : f.pack "top" "Down" = c m4    : window : f.pack "bottom"
 * 1) Ctl+Win+Right/Left: push window

"Tab" = m4   : all : f.forwiconmgr "a" = m4   : all : f.backiconmgr
 * 1) Win+Tab: forward in iconmgr
 * 1) Win+a: backward in inconmgr


 * 1) Pointer bindings

Button1 =   m : window|icon  : f.lower Button2 =   m : window|icon  : f.iconify Button3 =   m : window|icon  : f.raise
 * 1) In Windows, icons and iconmanager
 * 2) Raise/lower window with Button1 and Button3, iconify with Button2

Button1 =   : title       : f.move Button2 =   : title|frame : f.raiselower
 * 1) Move window with Button1 in title, Raise/lower it with Button 2

Button2 =   c : window : f.move
 * 1) Move window with C-Button2

Button3 =   c : window : f.resize Button1 =     : frame  : f.resize
 * 1) Resise window with C-Button3 and with Button1 on frame

Button1 = : icon : f.function "move-or-iconify"
 * 1) Move or de-iconify icons with button 1

Button4 =     : title          : f.squeeze Button5 =     : title          : f.squeeze
 * 1) Squeeze window with mouse wheel

Button1 =      : iconmgr       : f.iconify
 * 1)  raise window with a click on the icon manager


 * 1) Bind menus to pointer

Button1 =   : root : f.menu "defops" Button2 =   : root : f.menu "TwmWindows" Button3 =   : root : f.menu "TwmIcons"
 * 1) Mouse Buttons on the root window open main menus

Button1 = c : root : f.menu "TwmWorkspaces" Button2 = c : root : f.menu "TwmAllWindows" Button3 = c : root : f.menu "windowops"
 * 1) Cltr+Mouse Buttons on the root window open secondary menus

Button3 =   : title|iconmgr : f.menu "windowops"
 * 1) Open windowops menu also on windows titlebars and iconmanager

Variables
This is a typical Click-to-Focus Variables section, YMMV.
 * 1) GENERAL CTWM CONFIG

NoGrabServer
 * 1) Don't grab server when popupping up menus and moving opaque windows

UsePPosition "non-zero"
 * 1) Respect program-requested positions: "on", "off" or "non-zero"

Zoom 0
 * 1) Number of outline to be displayed when (de-)iconnifying a window


 * 1) Don't use the default titlebuttons and bindings
 * 2) NoDefaults

RandomPlacement "on"
 * 1) Place windows in a pseudo-random location: "on", "off", "all", "unmapped"

RestartPreviousState
 * 1) Remember if window was iconified when restarting window manager

RaiseOnClick
 * 1) Raise window when one click on it

RaiseOnClickButton 1
 * 1) Use Button 1 to raise a window


 * 1) Automticcally raise window when cursor enters the window
 * 2) AutoRaise


 * 1) if Autoraise, wait N ms before raising it
 * 2) RaiseDelay 250

AutoFocusToTransients
 * 1) Transient windows get focus automatically when created


 * 1) Don't send key events from the titlebar
 * 2) and icon managers to the application
 * 3) NoTitleFocus


 * 1)  Use sloppy Focus
 * 2) SloppyFocus

ClickToFocus
 * 1) Don't use pointer-driven keyboard focus, but click to focus


 * 1) WINDOWS RING

WindowRing { }
 * 1)        "AppsClassName"

WarpRingOnScreen
 * 1) f.wrapring warps only to windows visible in the current space

NoRaiseOnWarp
 * 1) Don't raise windows when pointer is wraped to them

WarpUnmapped
 * 1) Deiconify any iconified windows it encounters.

Bindings
This is a typical Click-to-Focus Bindings section, YMMV.
 * 1) Key bindings

IgnoreModifier { lock m2 }
 * 1) Ignore caps lock (lock) and num lock (m2) modifiers

"Up" 	=  c 	: all : f.prevworkspace "Down" 	= c 	: all : f.nextworkspace
 * 1) Change workspace with C-Up/Down

"Up"   =  c s	  : window : f.raise "Down" =  c s 	  : window : f.lower
 * 1) Raise/lower windows with C-S-Up/Down


 * 1) You can use your favorite keys to go directly
 * 2) the preferred apps
 * 3) "F5" =  : all : f.warpto "emacs"
 * 4) "F6" =  : all : f.warpto "Mozilla-bin"
 * 5) "F7" =  : all : f.warpto "bitchx"

"Tab" = m : window : f.warpring "next" "Tab" = c : window : f.warpring "prev"
 * 1) Walk the windowring using M-Tab/C-Tab
 * 2)  (you must define apps that go in the windowring, see WindowRing above)


 * 1) Workspaces and screens

"Up" = m4   : all : f.prevworkspace "Down" = m4   : all : f.nextworkspace
 * 1) Win+Up   : change workspace
 * 1) Win+Down : change workspace

"Left" = m4 : all : f.warptoscreen "back" "Right" = m4 : all : f.warptoscreen "next"
 * 1) Win+Right/Left: change screen


 * 1)  Windows placement

"Escape"       = c     : window        : f.iconify "Escape"       = m4    : iconmgr       : f.deiconify
 * 1) Iconify window with Ctrl+Esc, Deiconify with Win+Esc

"Left" = c m4    : window : f.pack "left" "Right" = c m4   : window : f.pack "right" "Up"   = c m4    : window : f.pack "top" "Down" = c m4    : window : f.pack "bottom"
 * 1) Ctl+Win+Right/Left: push window

"Tab" = m4   : all : f.forwiconmgr "a" = m4   : all : f.backiconmgr
 * 1) Win+Tab: forward in iconmgr
 * 1) Ctrl+a: backward in inconmgr


 * 1) Pointer bindings


 * 1) In Windows, icons and iconmanager

Button1 =   m : window|icon  : f.lower Button2 =   m : window|icon  : f.iconify Button3 =   m : window|icon  : f.raise
 * 1) Raise/lower window with Button1 and Button3, iconify with Button2

Button1 =   : title|frame : f.move Button2 =   : title|frame : f.raiselower
 * 1) Move window with Button1 in title, Raise/lower it with Button 2

Button2 =   c : window : f.move
 * 1) Move window with C-Button2

Button3 =   c : window : f.resize
 * 1) Resise window with C-Button3

Button1 = : icon : f.function "move-or-iconify"
 * 1) Move or de-iconify icons with button 1

Button1 =   : iconmgr : f.function "activate-me"
 * 1) Activate window from the incon manager with button1

Button4 =     : title          : f.squeeze Button5 =     : title          : f.squeeze
 * 1) Squeeze window with mouse wheel


 * 1) Bind menus to keys

Button1 =   : root : f.menu "defops" Button2 =   : root : f.menu "TwmWindows" Button3 =   : root : f.menu "TwmIcons"
 * 1) Mouse Buttons on the root window open main menus

Button1 = c : root : f.menu "TwmWindows" Button2 = c : root : f.menu "TwmWorkspaces" Button3 = c : root : f.menu "windowops"
 * 1) Cltr+Mouse Buttons on the root window open secondary menus

Button3 =   : title|iconmgr : f.menu "windowops"
 * 1) Open Window menu also on windows titlebars and iconmanager

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: 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.
 * 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.

CLEAN
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.
 * 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.