### The spectrwm window manager

The spectrwm window manager was inspired by xmonad and dwm. It shares several characteristics of dwm and has several nice features of its own, things that I always had to add to dwm with scripts or patches. The downside of that is that it's a bit bigger, with more dependencies, than dwm, but even on an old machine, it would be considered a very lightweight and fast window manager.

It was originally named scrotwm. Whether the humor was amusing, infantile, or both can be left to the judgement of the reader. Some people were offended and eventually the name was changed to spectrwm.

After installation, a default spectrwm.conf is created. If building from source, it will be in the spectrwm directory created after untarring the tarball. In Ubuntu based systems, as well as Fedora, it's /etc/spectrwm.conf. In FreeBSD it's /usr/local/etc/spectrwm.conf

Copy this file to your home directory.

    cd
    cp /etc/spectrwm.conf .spectrwm.conf

Note the period before the name in your home directory. That's making it a hidden file.

The file is fairly straightforward and has pretty sane defaults. The key bindings are described in the man page. Between the descriptions in the file and the man page, even the newcomer shouldn't have much trouble. This page is to just touch upon some things said newcomer may overlook.

Like many tiling window managers, Mod1 (the alt key), shift, and return launches an xterm by default. Mod1 and p will launch dmenu, which, if you're not familiar with it, is a very handy little application--it will appear by default, at the top of the screen and you can enter the name of an application into it. It has automatic tab completion, so if you enter the first few letters of thunderbird, for example, it will complete the word--you can then hit enter and it will launch thunderbird.

The first window, on the left, is the master window. As you add other windows, they will open in a stack on the right, automatically sizing themselves so that they can fit. To swap a window with the master window, Mod1 and return will put the focused window on the left, as the main window. So, you might have a browser on the left and two or three terminals on the right. If you're doing something involved in one terminal and need more top to bottom space, give it focus, hit Mod1 and return, and it's in the master window. Some prefer that new windows open in the master position, and all currently open windows get moved to the stack column. (This is the default behavior of dwm, for example). In such a case, find the line in your $HOME/.spectrm.conf that reads

    spawn_position    = last

and change the word last to read first.

The home page has some screenshots.

Hitting Mod1+l (lower case L) will expand the master window to the right. Hitting Mod1+h will shrink it to the left, or expand the stack on the right, depending upon your point of view. Those used to dwm will find the default keybindings fairly similar--using h and l to expand and contract the master are similar to movement keys in the vi editor. To focus on the next window use Mod1+j and Mod1+k moves to the previous window.

All of the above is common on many tiling window managers, but may help the novice as a 1 minute tutorial. Many people choose to customize their window manager, and this is where spectrwm shines, with a plain text configuration file and the ability to reload without restarting.

Let's start with the status bar. The default bar has more information than I need or want. I want the title of the focused window, the number of the workspace, and the date. Depending upon your version of spectrwm, you may have to manually add bar_format to your $HOME/.spectrwm.conf. A full description of the format is in the man page. To get what I want I use

    bar_format   =[+I] %R %F +C

The [+I] gives me the workspace number, and %R %F are the date format I prefer, giving me a time and date like 14:20 2014-11-14 (if it was 14:20 on the 14th of November in 2014, the day I'm writing this). The +C gives me the window class, which can be useful if I have a bunch of windows open. Spectrwm does identify the focused window by default, by having a 1 pixel red outline around it, but it can be useful to see it in the status bar as well. Some people prefer to have +W as well, for the window name. As far as I can see, if you have +C, +W or both in your bar_format line, you can leave the window_class_enabled and window_name_enabled at their default value of off. I haven't tested this too much, but it does seem that even if you turn them on, if you don't have the +C or +W in your bar_format line, you won't see a window name (or class) in the status bar.

One nice feature of spectrwm is that once you've changed your config file, MOD+q will reload it so that you can see your changes. (To quit spectrwm entirely use MOD+Shift+q). So, after making a change, hit MOD+q, and see if you like it.

A common change is the mod key. The default is Mod1, the alt key. Many people, including myself, prefer Mod4, the Windows key on a Windows keyboard, also known as Super. In your $HOME/.spectrwm.conf file, look for the line (like most defaults, it is commented out)

    # modkey   = Mod1

Change it Mod4 to have the Windows key be your usual mod key.

It has certain default programs--for example, the default terminal is xterm . You will see lines in your spectrwm.conf file like

    program[term] = xterm

If you preferred urxvt, you can change xterm to urxvt. Its default binding is MOD+Shift+Return. To disable any default binding, look for the section Validated default programs. In the section below it, you can see examples of how to disable validation, just uncomment the default bind keys. In practice, if you specify another binding, this probably isn't necessary. For example, I prefer to open dmenu with MOD+Shift+p as I use MOD+p for firefox--a habit formed long, long ago, when it was called phoenix. Even if I don't uncomment the default MOD+p for dmenu, MOD+p still opens firefox if I have it defined in my .spectrwm.conf.

To bind a program to a key, you must first define it with a program line. For example, if I want to open firefox with a key command, I must first define the program. They give an example of firefox, opening it to the spectrwm home page. Suppose I just want open the opera browser with the key combo of MOD+o. I first give it a name with a program line, then open it.

    program[opera]  = opera
    bind[opera]  	= Mod+o

The program line is necessary. It can be quite useful to, for example, open a program with specificed defaults. For example, if I want open irssi in a specifically colored terminal

    program[irc] 	= urxvt -bg black -fg white -e 'irssi -c irc.freenode.net'
    bind[irc] 	= MOD+i

(Either MOD or Mod will work.)

One very nice feature of spectrwm is that one can quickly, with the keyboard, toggle a window from tiled to floating and then, if it's floating, move it around and resize it. The keyboard shortcuts are in the man page, and can be added or changed in $HOME/.spectrwm.conf. MOD+t toggles the window to floating--then MOD+] moves it to right, MOD+[ to the left. MOD+- (the minus sign) shrinks the window's width. MOD+_ (the underscore, done with MOD+Shift+ the -_ key) shrinks the height. MOD+= increases the width and adding the Shift key, so that it's MOD++ (the plus sign) increases the height.

At work, I have 4 1600x900 monitors. I have NVidia cards and use the nvidia-settings program to make it run in Xinerama, one big screen. Using dwm, it seems to recognize screen boundries by default. With spectrwm, this should be configured in your .spectrwm.conf You will see a default commented out entry

    region 			=screen[1]:1280x1024+0+0
    region 			=screen[1]:1280x1024+1280+0

This refers to the screen resolution, X (left to right) and Y (top to bottom) positions. So, as all my monitors are 1600x900 I use

    region 			=screen[1]:1600x900+0+0
    region 			=screen[1]:1600x900+1600+0
    region 			=screen[1]:1600x900+0+900
    region 			=screen[1]:1600x900+1600+900

I'm not sure what that first [1] is for. The man page says idx but at any rate, in my setup, it stays at [1] for all of them. The first monitor, the upper left is at 0 and 0 that is, the far left and top edge of both X and Y axis. The second one is to the right, so it's at 1600 on the left to right axis and 0 on the Y axis. The third one is bottom left and so it's 0 for left to right and 900 on the Y axis and the last one, the bottom right, starts at 1600 on the left right axis and 900 at the up down axis. Some people may want larger regions, in which case they would make something like 3200x900+0+0. (To make one huge screen, I guess it would be 3200x1800, but in my case, I want each monitor to be a separate region.)

Each screen, when I do it this way, unlike dwm, has a different workspace number. If I have, for example firefox open on the top left, and thunderbird on the upper right, then, on the lower left, have something else, and then use MOD+2 on the lower left, it will now show me workspace 2, in other words, what was on the upper right monitor. The former workspace 2 will also change numbers. I've never actually kept track of this, as it only happens to me by mistake--generally what I want to do is open a fresh workspace, meaning I should use MOD+5, and hit 2 by mistake. Putting it back, by, while focused on the lower left monitor, doing MOD+3, puts all workspaces back to normal. MOD+Shift+number will moved a focused window to the workspace indicated by the number. In other words, if I want to move a terminal from workspace 3 to workspace 5, I focus on the terminal, hit MOD+Shift+5 and the terminal will now be on workspace 5.

With multiple monitors, you have to watch this--MOD+number won't switch focus to the screen with workspace 2, it will switch workspace 2 to the currently focused monitor. To move focus to a different monitor, the default key combination is MOD+<number> with the number being the keypad,rather than the number keys, which, as mentioned will switch the workspace within the monitor. The command is rg_n, with n referring to the number. One can also use rg_next and rg_previous. If you want, for example, to use MOD+N and MOD+P for next and previous regions (as MOD+p with lower case is already used)

    bind[rg_next]	= MOD+Shift+n
    bind[rg_prev]   = MOD+Shift+p

On FreeBSD, I've found that one has to install x11/fonts/fonts-misc-misc. Otherwise, if I try to start spectrwm with startx, it fails to start, complaining about missing fonts. (I installed spectrwm with pkg, this may not be true with ports. On Fedora, I wasn't able to get the rpm to work in 21 beta, latest F23 (in TC status as I write this), everything is fine. On older versions If I installed the git version, it worked as expected.

In CentOS 6,x I'm not able to get anything later than version 2.5.1 to compile. To get it to work, after extracting the tarball, I have to edit the linux/Makefile. There is a line that begins LDADD+=. To get it to compile I have to edit it so that it reads

    LDADD+= -lX11 -lX11-xcb -lxcb-aux -lxcb-icccm -lxcb-randr -lxcb-keysyms -lxcb-xtest -lXft -lXcursor

If your browser broke that, it should be on one line. In version 2.6 and above, the linux/Makefile doesn't have that line. The Makefile in the main directory has an LDADD line, but editing that didn't enable me to compile it. I should add that I have no knowledge of C, and it's possible that there's an easy fix, but with my relatively simple needs, version 2.5.1 is fine.

##