DEV Community

Cover image for Spectrwm: The Compact Window Manager
Angad Sharma
Angad Sharma

Posted on

Spectrwm: The Compact Window Manager

Spectrwm, is a small and minimalist tiling window manager. It is unlike manual WMs like bspwm and has more in common with dwm and i3. It was hilariously called scrotwm earlier.

Spectrwm is one of the more obscure window managers. I frankly didn't like it as much as some of the other WMs that I have tried so I had decided not to write an entry on it. But I realized that I gotta get my points out there since some of you guys might have different opinions about this window manager (and might be able to change mine as well).


Features

  • It is a dynamic tiling window manager.
  • It has a plaintext configuration file and can be reloaded during runtime.
  • It strives to be small, compact and fast.
  • It uses workspaces instead of tags for managing multiple windows.
  • Although spectrwm isn't well document by far (at least compared to i3), it is easy to configure due to the commented defaults.

Setting Up

Spectrwm is available on most source repositories. In addition, you can download the release and build it from source.

GitHub logo conformal / spectrwm

A small dynamic tiling window manager for X11.

spectrwm

spectrwm is a small, dynamic tiling and reparenting window manager for X11. It tries to stay out of the way so that valuable screen real estate can be used for much more important stuff. It has sane defaults, and it does not require one to learn a language to do any configuration. spectrwm is written by hackers for hackers and it strives to be small, compact, and fast.

spectrwm was largely inspired by xmonad and dwm. Both are fine products, but they suffer from things like: crazy-unportable-language syndrome, silly defaults, asymmetrical window layout, the 'how hard can it be?' (to code efficiently) problem, and good old NIH. Nevertheless dwm was a phenomenal resource, and good ideas and code were borrowed from it. On the other hand, xmonad has great defaults and key bindings, plus xinerama support, but it is crippled by not being written in C.

spectrwm is…

The easiest way to get started (on debian based systems) is this:

sudo apt install spectrwm
Enter fullscreen mode Exit fullscreen mode

To run it, simple add the following line in your ~/.xsession file:

exec spectrwm
Enter fullscreen mode Exit fullscreen mode

Logout and log back in again, and boom! You are good to go.

When you login to spectrwm, you get a basic menu bar which contains details like:

  • Which monitor you are on.
  • Which workspace you are on
  • Date and time

Spectrwm does not support some popular menu bars such as the beloved polybar, yabar and lemonbar. If you want to customize the menu bar, you can either write your own script or use an alternative that works with spectrwm, namely conky. In this blog we will be using conky to configure our menu bar.

All of the default keybindings of spectrwm can be seen in its man page (which is surprisingly comprehensive). Almost any problem while setting up spectrwm can be resolved by RTFM (Reading the Freaking Manual).

man spectrwm
Enter fullscreen mode Exit fullscreen mode

Layouts

Spectrwm comes with 3 layouts mainly. You can switch between these layouts using the Mod + Spacebar keys. The default modifier in spectrwm is the windows key (Mod4).

  • Vertical Master-Stack Layout: This is the default layout in spectrwm. Here your left window will be the master, and every window you create after that will keep on stacking on the right hand side. This is also the default layout in dwm.

Alt Text

  • Horizontal Master-Stack Layout: This is similar to the master-stack layout only. But here the master is at the top horizontal window split and each new spawn vertically splits the bottom horizontal split of the window.

Alt Text

  • Full Screen: In this layout, all windows occupy 100% of your screen space. They can then be switched back and forth by using the Mod + j|k keys.

Alt Text


Configuration

The default configuration file of spectrwm is ~/.spectrwm.conf. There is an example configuration available at /etc/spectrwm.conf. You can copy it to your home folder to get started.

As soon as you go inside the file, you will notice that all of the important functionalities that you might customize in a window manager are already commented. Whenever you make a change in the configuration, just press the Mod + q key to restart spectrwm.

Configuration in spectrwm is pretty self explanatory so I wont be diving deeper. I will just touch on these three subjects:


Key Bindings

The bind function can be used for mapping programs to keys in spectrwm. Now this might not be obvious but there is a separate configuration file with a LOT of key bindings specified beforehand. You can head over to the official spectrwm repository to take a look at the keybinding configurations. All of the configuration files with country ISO codes ahead of them (eg: spectrwm_fr.conf) are the files which you need to look at.

You can paste the contents of spectrwm_us.conf in your ~/.spectrwm.conf and fiddle around with the keybindings to suit your needs. The syntax is pretty easy to understand:

bind[<action>] = <keybinding>
Enter fullscreen mode Exit fullscreen mode

Quirks

You can associate a certain program to open a certain way using quirks. They can be thought of as modifiers which limit (or extend) the actions of a specific program in a window. For example:

# quirk[Firefox:Dialog]         = FLOAT
# quirk[Gimp:gimp]  
Enter fullscreen mode Exit fullscreen mode

The format of a quirk is the following:

quirk[<class>:<name>] = [NONE | FLOAT | ANYWHERE | FULLSCREEN | FOCUSPREV]
Enter fullscreen mode Exit fullscreen mode

The class name of a program is actually the class name we get after selecting a window in xprop mode. It is the official X11 name of a particular window:

# how to get the class name of a window
xprop | grep WM_CLASS
Enter fullscreen mode Exit fullscreen mode

Conky Bar Setup

If you take a closer look at the bar section of a spectrwm configuration, there is an option called bar_action. You can map it to a custom script if you want. You can also map it to conky, if you want to use it:

bar_action = conky
Enter fullscreen mode Exit fullscreen mode

Conky is a lightweight system monitor for X11 that can be used to display any kind of information on your desktop. It needs a configuration file at ~/.conkyrc. This is how my conkyrc looks like:

out_to_x no
out_to_console yes
update_interval 1.0
total_run_times 0
use_spacer none
TEXT
[ ${time %R %a,%d-%#b-%y} ] [ Mail:${new_mails} ] [ Up:${uptime_short} ] [ Temp:${acpitemp}C ] [ Battery: ${battery_percent BAT1}% ${alignr}${battery_bar 3,20 BAT1} ] [ ${addr wlp0s20f3} ] [ RAM:$memperc% ] [ CPU:${cpu}% ] [ ${downspeedf wlp0s20f3} Mbps ]
Enter fullscreen mode Exit fullscreen mode

Refresh your spectrwm and you will get a bar like this:

Alt Text

To learn more about conky, you can head over to its official repository:

GitHub logo brndnmtthws / conky

Light-weight system monitor for X.

Linux build macOS build Docker build AppImage build

pipeline status coverage report

💬 Join the Matrix chat

Conky is a free, light-weight system monitor for X, that displays any kind of information on your desktop.

👉 Grab the latest release from GitHub.

📹 An introduction to Conky (YouTube).

Features

Conky can display more than 300 built-in objects, including support for:

  • A plethora of OS stats (uname, uptime, CPU usage, mem usage, disk usage, "top" like process stats, and network monitoring, just to name a few).
  • Built-in IMAP and POP3 support.
  • Built-in support for many popular music players (MPD XMMS2, Audacious).
  • Can be extended using built-in Lua support, or any of your own scripts and programs (more).
  • Built-in Imlib2 and Cairo bindings for arbitrary drawing with Lua (more).
  • Runs on Linux, FreeBSD, OpenBSD, DragonFlyBSD, NetBSD, Solaris, Haiku, and macOS!
  • Docker image available for amd64, armv7, and aarch64 (aka armv8)


Why I don't like spectrwm

Some of you might not agree with this section. But know that some of these points are facts and others are just my opinions. They might not be a deal breaker for you. Some of these are some issues that I faced while dealing with spectrwm, even after RTFM, so I felt like I needed to mention it for all of the new users who might want to try spectrwm out.

  • Spectrwm does not support external compositing. Which means compton or picom will simply not work with it. You can say goodbye to window animations, drop shadows and transparency

  • As mentioned earlier, spectrwm does not support third party menu bars such as polybar, lemonbar or yabar. Which is kind of stupid due to it's similarities with i3 and dwm.

  • When you install spectrwm, there is a bug which forces certain programs to open up on certain workspaces only. This is annoying if you are working on workspace 1 and you want to spawn a terminal on the same workspace but it ends up on workspace 6 without any reason. Although this bug can be solved by adding a simple quirk, but due to design decisions, it can not be included with the base spectrwm build.

  • While using spectrwm, I have noticed that it remembers the exact layout of your previously opened tiles in a particular workspace. For example if I open 3 terminals and resize each and every one of them, the next time I open 3 terminals on the same workspace, they are going to be the same size. This might be an annoyance if you don't want your windows to be the same size everytime.

  • I noticed a very weird thing that started happening in my WM. Whenever I opened some windows on a workspace which already has a window, they spawned behind the current window. This caused a lot of annoyance since I was not able to figure out if my windows were even being spawned or not. Later on I realized that it was because fullscreen mode and I had no indication that it was configured only for that particular workspace. As I mentioned earlier, spectrwm also memorizes layout on a per-workspace basis. Which is very different from other WMs.


Verdict

Spectrwm has it own array of annoyances and incompatibilities. But the more I think about its design philosophies, the more convinced I am that these incompatibilities are intentional.

Spectrwm aims at being a very minimal and lightweight window manager, not just in terms of lines of code and bulk but in terms of usage. If you are someone who does not want any aesthetic distractions, wants to make the full use of screen real estate, then this is the WM for you.

Judgement Rubric Rating
Simplicity of use ❤️ ❤️ ❤️
Simplicity of Configuration ❤️ ❤️ ❤️
Learning curve (lesser is better) ❤️ ❤️ ❤️
Productivity ❤️ ❤️ ❤️
Fun ❤️ ❤️ ❤️

Top comments (3)

Collapse
 
jsierrab3991 profile image
Masataka Takayanagi

My configuration: github.com/jSierraB3991/dotfiles/b...

image

Collapse
 
etrigan63 profile image
Carlos Echenique • Edited

Um, I use spectrwm with picom and polybar all the time.
dev-to-uploads.s3.amazonaws.com/i/...

Collapse
 
twb0109 profile image
Brandon Sánchez

I don't know if this is allowed, but I have my config over on github, and it should solve most of the annoyances you have with it. github.com/TWB0109/PDots.

Delete if not allowed, np.