Edit detail for getting started with cwm revision 2 of 2

1 2
Editor: rgouveia
Time: 2009/05/04 20:29:57 GMT+2
Note:

changed:
-(From now on I will use C to symbolize Ctrl, M for Alt, S for Shift, M1 left mouse button and 
(From now on I will use C to symbolize Ctrl, M for Alt, S for Shift, M1 left mouse button, M2 middle mouse button and 

changed:
-or C-M-= to maximize it vertically. You can also move it using the mouse (M-M1) or resize it (M-M1-M2).
or C-M-= to maximize it vertically. You can also move it using the mouse (M-M1) or resize it (M-M2).

Getting started with cwm

For some time now cwm (calm window manager) has been part of the OpenBSD Xorg installation. 
I've been fond of it since I tried it last year. Lately I've been exploring and would like to share my findings.
I divided them in simple topics ending with my current configuration file (~/.cwmrc).

Initial impressions 

When starting cwm we get only a "blank desktop". I personaly use "xsetroot -solid steelblue" as a background.
Let's start with the default key binding of Ctrl-Alt-Enter which will open a xterm. 
(From now on I will use C to symbolize Ctrl, M for Alt, S for Shift, M1 left mouse button, M2 middle mouse button and 
M3 for the right mouse button. This follows the cwm man page notations.)
Now that we have that xterm open we can manipulate it's window. C-M-f to make it full-screen,
or C-M-= to maximize it vertically. You can also move it using the mouse (M-M1) or resize it (M-M2).
Close it with C-M-x.
You can run other applications by pressing M-? . This will popup the exec dialog on which you can 
type the name of the application that you want to run. You will see it tries to autocomplete the 
name of the program. Just press Return when it shows what you want and the application will start.
Add your favorite applications to cwmrc so you can access them through the right mouse button M3.


Virtual Desktops

Let's imagine that we have this xterm running and another program by it's side: firefox.
We can alternate between both with M-tab. Or we could use virtual desktops.
In cwm this can be accomplished with groups. Each window can be assigned to a group with C-M-[n],
"n" being a number between 1 to 9, moving the focus of the mouse to the window we want and pressing
C-M-g. You will see a temporary blue border around the window when it's assigned a group and red 
when it's removed.
In our example we will press C-M-1, move the cursor to the xterm and press C-M-g. 
We will do the same for firefox and assign it to group 2.
Now even though you assigned different groups to each window, you're still seeing both. That happens 
because cwm is showing all groups (C-M-0). Let's just select group 2 (firefox) with C-M-2. This will 
show us all of group 2 windows. And you can get back to xterm with C-M-1.
You can also cycle through groups with M-right or M-left.

Inherit the group when opening a window

You will notice when you open a window that, by default, it won't be assign membership to a specific group.
We can change this by adding the option "sticky" on cwmrc.
That will make each window inherith the group in which was opened.

Automatic window grouping

We can also automatically assign a window to a group based on it's class and/or name properties. By using xprop
we can get these properties. xterm has a useful -class switch, which I use it to set my ssh connection to
my mail server simply as mail instead of the default xterm so I can distinguish it.
Again this configuration is done through cwmrc.


This should be enough to get you started. Don't forget to read the cwm and cwmrc man pages.
So without further due here's my cwmrc:

# customize some bindings (C-control M-alt M1-button1)
bind M-r        exec
bind CM-r       reload
bind CM-l       label
bind CM-t       "xterm -e \"top -s 0.6\""
bind CM-m       menusearch
mousebind M-1   window_move
mousebind CM-1  window_resize

# application menu
command pidgin  pidgin
command xchat   xchat
command silc    "xterm -class silc -e mysilc.sh"
command mail    "xterm -class mail -e \"ssh my.mail.host\""
command firefox firefox

# groups predefined, use xprop to get these from each program
autogroup 2     "Navigator,Firefox"
autogroup 2     "Dialog,Firefox"
autogroup 3     "pidgin,Pidgin"
autogroup 3     "xchat,Xchat"
autogroup 3     "xterm,silc"
autogroup 4     "xterm,mail"

# inherit current selected group
sticky yes