Guide to X11/Window Managers/ctwm

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Type: stacking Language: C License: GPL

Claude's Tabbed Window Manager[edit | edit source]

CTWM 3.7 screenshot captured on Debian 7 GNU/Linux
CTWM 3.7 screenshot captured on Debian 7 GNU/Linux

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[edit | edit source]

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[edit | edit source]

Features of the CTWM window manager include:

Using CTWM[edit | edit source]

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[edit | edit source]

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[edit | edit source]

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).

WorkSpace Operations[edit | edit source]

Managing Icons[edit | edit source]

Configuring CTWM[edit | edit source]

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[edit | edit source]

Variables[edit | edit source]

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

### GENERAL CTWM CONFIG 

## Don't grab server when popupping up menus and moving opaque windows
NoGrabServer

## Respect program-requested positions: "on", "off" or "non-zero"
UsePPosition "non-zero"

## Don't use the default titlebuttons and bindings
#NoDefaults

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

## Remember if window was iconified when restarting window manager
RestartPreviousState

## Raise window when one click on it
#RaiseOnClick

## Use Button 1 to raise a window
#RaiseOnClickButton 1

## Automticcally raise window when cursor enters the window
AutoRaise

## if Autoraise, wait N ms before raising it
RaiseDelay 250

## Transient windows get focus automatically when created
AutoFocusToTransients

## Transient window on top if n% smaller than parent window
TransientOnTop 50

## Don't send key events from the titlebar 
## and icon managers to the application
#NoTitleFocus

# Use sloppy Focus
#SloppyFocus

# Don't use pointer-driven keyboard focus, but click to focus
#ClickToFocus

# Don't wait for the cursor to cross an edge to resize the window
AutoRelativeResize

# Don't move windows Off the screen
#DontMoveOff

# Moving the small window in the WorkspaceManager will move the actual window
ReallyMoveInWorkspaceManager

# Keep menus up if the cursor has not yet been entered by the pointer
StayUpMenus

### WINDOWS RING 

WindowRing {
##        "AppsClassName"
}

## f.wrapring warps only to windows visible in the current space
WarpRingOnScreen

## Don't raise windows when pointer is wraped to them
NoRaiseOnWarp

## Deiconify any iconified windows it encounters.
WarpUnmapped

Bindings[edit | edit source]

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

## Key bindings

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

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

# You can use your favorite keys to go directly 
# the preferred apps
#"F5"  =  : all : f.warpto "emacs"
#"F6"  =  : all : f.warpto "Mozilla-bin"
#"F7"  =  : all : f.warpto "bitchx" 

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

## Workspaces and screens

# Win+Up   : change workspace
"Up" = m4    : all : f.prevworkspace
# Win+Down : change workspace
"Down" = m4    : all : f.nextworkspace

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


## Windows placement

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

# Ctl+Win+Right/Left: push window
"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"

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

# Pointer bindings

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

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

## Move window with C-Button2
Button2 =    c : window : f.move

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

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

# Squeeze window with mouse wheel
Button4 =      : title          : f.squeeze
Button5 =      : title          : f.squeeze

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

## Bind menus to pointer

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

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

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

Click-to-Focus[edit | edit source]

Variables[edit | edit source]

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

### GENERAL CTWM CONFIG 

## Don't grab server when popupping up menus and moving opaque windows
NoGrabServer

## Respect program-requested positions: "on", "off" or "non-zero"
UsePPosition "non-zero"

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

## Don't use the default titlebuttons and bindings
#NoDefaults

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

## Remember if window was iconified when restarting window manager
RestartPreviousState

## Raise window when one click on it
RaiseOnClick

## Use Button 1 to raise a window
RaiseOnClickButton 1

## Automticcally raise window when cursor enters the window
#AutoRaise 

## if Autoraise, wait N ms before raising it
#RaiseDelay 250

## Transient windows get focus automatically when created
AutoFocusToTransients

## Don't send key events from the titlebar 
## and icon managers to the application
#NoTitleFocus

# Use sloppy Focus
#SloppyFocus

# Don't use pointer-driven keyboard focus, but click to focus
ClickToFocus


### WINDOWS RING 

WindowRing {
##        "AppsClassName"
}

## f.wrapring warps only to windows visible in the current space
WarpRingOnScreen

## Don't raise windows when pointer is wraped to them
NoRaiseOnWarp

## Deiconify any iconified windows it encounters.
WarpUnmapped

Bindings[edit | edit source]

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

## Key bindings

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

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

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

# You can use your favorite keys to go directly 
# the preferred apps
#"F5"  =  : all : f.warpto "emacs"
#"F6"  =  : all : f.warpto "Mozilla-bin"
#"F7"  =  : all : f.warpto "bitchx" 

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


## Workspaces and screens

# Win+Up   : change workspace
"Up" = m4    : all : f.prevworkspace
# Win+Down : change workspace
"Down" = m4    : all : f.nextworkspace

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


## Windows placement

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

# Ctl+Win+Right/Left: push window
"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"

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


# Pointer bindings

## In Windows, icons and iconmanager

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

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

## Move window with C-Button2
Button2 =    c : window : f.move

## Resise window with C-Button3
Button3 =    c : window : f.resize

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

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

# Squeeze window with mouse wheel
Button4 =      : title          : f.squeeze
Button5 =      : title          : f.squeeze


## Bind menus to keys

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

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

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

Window Decorations[edit | edit source]

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[edit | edit source]
Open Windows using olwm.
Open Windows using olwm.

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[edit | edit source]
ICE default "Look" (TWM)
ICE default "Look" (TWM)

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[edit | edit source]
Motif default "Look" (MWM)
Motif default "Look" (MWM)

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.

Gnome Desktop
Gnome Desktop's "CLEAN" style.
CLEAN[edit | edit source]
  • 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.

Menus[edit | edit source]

Review[edit | edit source]