OpenBSD Journal

Getting started with cwm

Contributed by maxime on from the calm-like-a-bomb dept.

Reader Rodolfo Gouveia (rgouveia) came up some days ago with this story:

For some time now cwm (calm window manager) has been part of the OpenBSD X.org 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 and M3 for the right mouse button. This follows the cwm man page notations.)

Now that we have that xterm open we can manipulate its 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-M1-M2). Close it with C-M-x. You can run other applications by pressing M-?. This will pop up the exec dialog on which you can type the name of the application that you want to run. You will see it tries to auto-complete 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 its 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. 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 assigned membership to a specific group. We can change this by adding the option "sticky" in .cwmrc. That will make each window inherit the group in which was opened.

Automatic window grouping

We can also automatically assign a window to a group based on its class and/or name properties. By using xprop we can get these properties. xterm has a useful -class switch, which I use 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(1) and cwmrc(5) man pages.

So without further ado 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 3     "pidgin"
autogroup 3     "xchat"
autogroup 3     "xterm,silc"
autogroup 4     "xterm,mail"

# inherit current selected group
sticky yes

(Comments are closed)


  1. By Anonymous Coward () on

    fluxbox is 10 trillion times better.

    tiled managers are fail, go back to Windows 3.1 you retard.

    1. By Anonymous Coward () on

      > fluxbox is 10 trillion times better.
      >
      > tiled managers are fail, go back to Windows 3.1 you retard.

      cwm isn't a tiling wm.

    2. By Anonymous Coward () on

      > fluxbox is 10 trillion times better.
      >
      > tiled managers are fail, go back to Windows 3.1 you retard.

      Oh hai!
      U fail at trolling.

    3. By Anonymous Coward () on

      Oh wait....Linux teen is talking to us.All must stop their work and listen to this noobish crap :-D

      > fluxbox is 10 trillion times better.
      >
      > tiled managers are fail, go back to Windows 3.1 you retard.

    4. By Anonymous Coward () on

      > fluxbox is 10 trillion times better.
      >
      > tiled managers are fail, go back to Windows 3.1 you retard.

      That's kinda tells everything from the commentator.

  2. By Anonymous Coward () on

    Thank you for this details view in cwm. I use it since some month and I love it. Is there anybody who know, how to bind the unhide_menu on a key (standard is left mouse on the root window)? Is it possible?

  3. By Anonymous Coward () on

    Since we're already sharing, here's mine (I was surprised to see that you don't use the Super key but perhaps you don't have it?):

    # ~/.cwmrc

    sticky yes

    # Override built-in term command
    command term "xterm +vb +sb -ls -fn 9x15 -bg black -fg white -geometry 80x30"

    # Keybindings: commands
    bind 4-t terminal
    bind 4-r exec
    bind 4-g firefox
    bind 4-e "emacs -geometry 80x40"
    bind 4-d gnome-dictionary
    bind 4-b sylpheed
    bind 4-comma "mixerctl outputs.master=-5"
    bind 4-period "mixerctl outputs.master=+5"
    bind 4-m "xmms -f"
    bind 4-n "xmms -r"

    # Keybindings: windows
    bind 4-f maximize
    bind 4-q delete
    bind 4-j cyclegroup
    bind 4-k rcyclegroup
    bind 4-l label
    bind 4-h hide
    bind 4-v vmaximize

    1. By Anonymous Coward () on

      > # ~/.cwmrc
      >
      > sticky yes
      >
      [...]

      Might as well include my .xinitrc for completeness:

      xv -root -quit images/background.png
      pgrep aucat || /usr/bin/aucat -l &
      xset b off
      xset r rate 250 80
      ssh-agent cwm

      1. By thoren () on

        > xv -root -quit images/background.png

        feh is a great in-ports replacement for xv. it'll do most everything xv will, including bg stuff, and its lic is a little less odd.

        1. By Anonymous Coward () on

          > > xv -root -quit images/background.png
          >
          > feh is a great in-ports replacement for xv. it'll do most
          > everything xv will, including bg stuff, and its lic is a
          > little less odd.

          Thank you for that. xv now replaced by feh (because of the
          licensing issues that I was not aware of). Don't like that
          it have to create two new dot-files, but I guess I can live
          with it ;-)

        2. By Anonymous Coward () on

          > > xv -root -quit images/background.png
          >
          > feh is a great in-ports replacement for xv. it'll do most everything xv will, including bg stuff, and its lic is a little less odd.

          Feh has more dependency's than xv, did you check the dependency's licenses too?

          1. By thoren () on

            > > > xv -root -quit images/background.png
            > >
            > > feh is a great in-ports replacement for xv. it'll do most everything xv will, including bg stuff, and its lic is a little less odd.
            >
            > Feh has more dependency's than xv, did you check the dependency's licenses too?

            $ cat /var/db/pkg/feh-1.3.4/+REQUIRING
            jpeg-6bp3
            giblib-1.2.4p3
            png-1.2.33
            imlib2-1.4.0p0

            jpeg, and png are already brought in by firefox (for those that use it). giblib is written by the same guy that writes feh, and is marked # BSD in its ports makefile along with imlib2 and png. the trickiest one there is jpeg, which is also required by xv and xloadimage, and still doesn't appear that tricky. as far as graphics progs that will display modern formats to the root window go, it's the most benign useful thing i know. if you are aware of sth even better, i'd love to hear it.

    2. By Anonymous Coward () on

      > Since we're already sharing, here's mine (I was surprised to see that you don't use the Super key but perhaps you don't have it?):
      >
      > ...

      Hi, what's the Super-Key?

      1. By Anonymous Coward () on

        > Hi, what's the Super-Key?

        aka. the Windows key.

    3. By rgouveia (rgouveia) on http://cosmico.net

      > # Override built-in term command
      > command term "xterm +vb +sb -ls -fn 9x15 -bg black -fg white -geometry 80x30"

      I use ~/.Xdefaults:

      XTerm*loginShell: true
      Xft.antialias: true
      xterm*faceName: mono
      xterm*faceSize: 14
      xterm*cursorBlink: true
      xterm*visualBell: false
      xterm*background: yellow
      xterm*foreground: black


      Also look at /etc/X11/app-defaults/Xterm

      1. By Anonymous Coward () on

        > xterm*background: yellow

        Whoa, do you fear sleeping in front of the monitor? ;)

  4. By Predrag Punosevac () on

    OpenBSD journal is one of the best readings for Unix geeks. The article about Calm Window Manager is no exception. Spot on!!! Great job.

    Personally, I would like to thank OpenBSD developers for cleaning CWM from bugs and adding new features. Anybody who tried to use vanilla version of CWM will know what I am talking about. I have been using CWM for almost a year now and I would not go back to OpenBox unless somebody points the gun into my head. Presently, when most "enterprise" operating systems Unix like or not need 4GB or RAM and 2 cores just to boot OpenBSD is like a breath of a fresh air.

    To all of those who think that CWM is for Unix geeks only I can attest that my wife loves it as well. She is about as far as it gets from being Unix geek.

    Finally, I would like to share with you my favorite key binding for CWM.

    # Email client Heirloom mailx way 
    bind    CM-g   "xterm -e nail -A gmail"
    

    1. By Dmitry () on http://deoxyt2.livejournal.com

      > OpenBSD journal is one of the best readings for Unix geeks. The article
      > about Calm Window Manager is no exception. Spot on!!! Great job.
      >
      >
      > Personally, I would like to thank OpenBSD developers for cleaning CWM from bugs and adding new features. Anybody who tried to use vanilla version of CWM will know what I am talking about. I have been using CWM for almost a year now and I would not go back to OpenBox unless somebody
      > points the gun into my head. Presently, when most "enterprise" operating systems Unix like or not need 4GB or RAM and 2 cores just to boot OpenBSD is like a breath of a fresh air.
      >
      >
      > To all of those who think that CWM is for Unix geeks only I can attest
      > that my wife loves it as well. She is about as far as it gets from being Unix geek.
      >
      >
      > Finally, I would like to share with you my favorite key binding for CWM.
      >
      >
      >
      > # Email client Heirloom mailx way
      > bind CM-g "xterm -e nail -A gmail"
      >

      My CMW no have border in xterm or any program, but I donīt stand, wath is the problem?

      1. By Anonymous Coward () on

        > My CMW no have border in xterm or any program, but I donīt stand,
        > wath is the problem?

        Set borderwidth. If that doesn't do anything, you might want to
        talk to misc@openbsd.org or something like that.

    1. By Seth () seth@2t3k.com on

      > scrotum rocks

      My first reaction was "Wtf, is that a joke?"

      Apparently not

      1. By Anonymous Coward () on

        > > scrotum rocks
        >
        > My first reaction was "Wtf, is that a joke?"
        >
        > Apparently not

        Never used a tiling wm then. Try it out sometime. Less mousejerking to get work done.

        1. By Russell () @dotplan.dyndns.org on

          Right, I ended up using wmii, Screw the whole broken desktop metaphor.

          Have you ever said "Boy, I sure am glad Window foo is overlapping window bar!" Changing to point to focus(not raise) mitagates the pain a little. But you usually want to be in one of two modes anyhow, one window fullscreen, or multi window with full access, I have never needed a half obscured window.

          Exceptions and downsides, i.e. the incompleteness theorem.

          Small notification windows, they are better not shifting your layout around. but... design wise, no window should ever lock another window, why are you using a multiple access design and preventing access? real solution, a status/mode change area to handle locking events.

          programs that don't flow well, some programs are just too dependent on being able to set the window size. They tend to freak out on a tiling wm. I actually have not seen too many off them, so I can't think of any examples.

          So take the plunge, start tiling, learn/set the hotkeys. it is how windowing should be.


      2. By Anonymous Coward () on

        > scrotwm rocks
        >
        >
        > My first reaction was "Wtf, is that a joke?"
        >
        >
        > Apparently not

        Hellyeah. And you love it.

  5. By Anonymous Coward () on

    CWM is a great wm. I wish to meet a tiling enable/disable function by keybinding in it. A combination of cwm and scrotwm would be awesome.

    1. By jason (jason) on http://www.dixongroup.net/

      > CWM is a great wm. I wish to meet a tiling enable/disable function by keybinding in it. A combination of cwm and scrotwm would be awesome.

      Scrotwm allows you to toggle (Mod-T).

    2. By Anonymous Coward () on

      > CWM is a great wm. I wish to meet a tiling enable/disable function by keybinding in it. A combination of cwm and scrotwm would be awesome.

      awesome.naquadah.org :-p

      1. By Anonymous Coward () on

        > > CWM is a great wm. I wish to meet a tiling enable/disable function by keybinding in it. A combination of cwm and scrotwm would be awesome.
        >
        > awesome.naquadah.org :-p

        Awesome is not bad but need to many depends like lua etc.

        CWM is nearly perfect in my eyes. It need just the possibility to switch to float mode my a hotkey to arrange the windows on the screen. Then you can create groups with and without floating etc... but this is just a dream and will never realized. NP, I love CWM with or without tiling mode. :)

    3. By Owain G. Ainsworth (oga) on

      > CWM is a great wm. I wish to meet a tiling enable/disable function by keybinding in it. A combination of cwm and scrotwm would be awesome.

      I may do this eventually. Maybe.

      I accept diffs, though.

  6. By Martin Toft () on

    You can also use cwm on Linux :-)

    It saves the day when you are forced to work in a penguin environment...

    http://martintoft.dk/?p=cwm

  7. By rgouveia (rgouveia) rgouveia@cosmico.net on http://cosmico.net

    I would like to make some corrections.
    It seems the class and name has to be specified and not just one or the other.
    So on my cwmrc, pidgin and xchat go like this:

    autogroup 3 "pidgin,Pidgin"
    autogroup 3 "xchat,Xchat"

    I've also discovered that cwm wouldn't assign firefox dialogs along with the same group window as the main program. That was because the name of the window was different, so I had to add another entry:

    autogroup 2 "Navigator,Firefox"
    autogroup 2 "Dialog,Firefox"

    1. By rgouveia (rgouveia) on http://cosmico.net

      More corrections:
      1. I forgot to mention that M2 is the middle mouse button.
      2. The default window resize command is M-M2.

  8. By Anonymous Coward () on

    Great work on the CWM.

    I tried it at some point but didn't really like it back then.
    Currently running simple, manual tiling wm (musca) that fills my desktop needs quite nicely.
    If I had to use other than musca I might try cwm again though. Its clean and simple like OpenBSD :)

  9. By sthen () on

    cwm just gained a couple of new features, grouponly and movetogroup which give a different way to work with groups that you'll be familiar with if you've used dwm/scrotwm/xmonad. if you like some things about cwm but can't quite get your head around how it handles groups, this could be for you...

Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]