Lessons learned from using xmonad for a year

Last year I switched from KDE to xmonad; here are my experiences.

Last year I switched to xmonad in the strive for a configurable yet minimalist environment. So far I am pretty satisfied with it. I’ve never experienced any crashes or slowdowns related to it, works easily for most of the tasks, and supports multi monitor setup. It is highly configurable and well documented, so it’s easy and fun to customize the whole environment to suit your unique workflows.

In fact, it’s so minimal by default, that my first task was to figure out how I would use my system and configure it configure accordingly.

I think it’s great to stop sometimes and rethink our tools and processes, explore different means to solve day-to-day problems and identify what could be improved. I like tinkering and seeking new stuff in my free time anyway, so starting with a minimalistic environment was very inspiring, because it forced me to rethink even some of the basic aspects of my workflows.

To illustrate how minimalistic it is by default, I show you a screenshot:

Very first impressions

By default it provides almost all features you might need to get comfortably around without being in the way. Let’s see what you can do in this seemingly empty environment and how to get there.

The beginnings

Previously I observed that I use virtual desktops in a way that most of them has one application opened all the time, and in a few I have 2-3 terminals and SQL clients side-by-side, so I can read contents from all of them. Because I always arranged my windows the same way, I’ve set out to find a tiling window manager that automates it for me.

This is how I bumped into xmonad. From the docs and posts I’ve found it seemed that it’s design is less focused on initial intuitiveness, while putting more emphasis on effectiveness and minimalism. It requires familiarity with some basics, but after the initial period you can get around much quicker.

I decided to keep my KDE setup, and gradually move to xmonad and continue using KDE software that I like. Luckily, it’s easily possible, if I remember correctly installing xmonad did not harm my existing DE in any way. (Some xmonad tutorials encourage to change the xsession.rc file. When you do that, be careful, because it might interfere with your other desktop environments.)

The blank screen that I’ve shown you might be startling at first, but at this point you are only one mod+shift+enter away from opening a terminal, and with mod+p you can run any program. (The mod key is bound to alt by default, but it can be changed. I remapped it to the Windows key, because there are many programs that offer shortcuts with alt.) The default xmonad configuration is pretty user friendly, as it is described here, with a few keystrokes you can select, move or close windows that are automatically arranged by the selected layout strategy. Each workspace can have different layout strategy which can be dynamically selected and configured. With multiple monitors each screen has one workspace visible that can be chosen independently from the workspaces on the other displays. To my surprise it supports floating windows as well, so if you open a Save File dialog, it won’t mess with the layout, just presents the dialog gently floating above the other windows. (You can easily sink a floating window to the grid if you need to.)

Grid with floating window

If you are convinced, getting xmonad is easy. It only takes to install the xmonad package and the suckless-tools for some essentials.

sudo apt-get install xmonad suckless-tools

Making it more comfortable

The default configuration allows to do anything in this minimalist world, but some old habits die hard and I wanted to keep some parts of my old environment, for example a good screen locker, toolbar or tray with current date and volume etc.

Xmonad can be easily configured and extended. There is an excellent tutorial about installing some essentials that is worth checking out, but a quick Google search will usually lead you to a friendly forum where most of the typical questions are already answered.

In this post I try to cover the most interesting stuff, but all my xmonad related configurations can be found in my dotfiles repository.

With these and the user friendly defaults, I am using exclusively xmonad for a while now, and it is a breeze. It’s fast and everything I need is at my fingertips, or even better: I can easily augment the environment according to my needs.

Status bar with time display, custom volume control and Google Calendar integration

The thing that I missed the most is a tray or status bar where all the ambient information is presented. There are many viable alternatives, but xmobar was the closest to my liking.

It “is a minimalistic, mostly text based, status bar” which can be easily extended with plugins and output templates. There are plugins for the most common tasks, such as date and time display and to show cpu utilization, and it can run any arbitrary program for you and show its standard output on the status bar. Somewhere I found a script that visualizes the current volume level with dashes and greater than symbols. Based on this idea, I created another script that displays the signal strength for the wifi connection and included both of them on my status bar. It’s incredibly fun to customize the status bar with simple shell scripts.

Custom volume and wireless signal widgets on the status bar

The status bar elements can be configured to respond to various user actions, such as mouse clicks. Because I frequently need a calendar, I enhanced the displayed date. Now when I click on it, a gsimplecal pops up. It’s a lightweight calendar tool that nicely fits into this customizable world, because it can run any program when the a date is selected. I configured mine to open the corresponding week in Google Calendar, so I can see my events.

I used KOrganizer before, but it was too slow to startup and too heavy-weight for my needs as it contains not just a calendar, but everything else related to scheduling events.

gsimplecal

Finally, there was only one status bar related thing left unsolved: finding a way to hide it. I’ve already set up my layout strategies (I usually either arrange windows vertically, or select one to take the full screen), but the permanent status bar can really demolish the movie watching experience.

Fortunately there is an easy way to toggle the statusbar.

Quest for the best window focus indicator

The next thing that bothered me was that by default, xmonad indicates window focus with a thin border.

It mostly bothered me because it makes a bit harder to grab scrollbars at the edges of the screen. I modified my config to use padding rather than border to separate the windows, and to indicate which window is focused, I modified my config to apply some transparency on the unfocused windows. In this setup a nice wallpaper can be shown in the space between the windows, and faintly through the unfocused ones as well. This setting is really appealing in a simple screenshot, but as it quickly turned out not too practical.

Slight fading indicates the selected window, plus some padding

If the windows are not opaque enough then it’s really hard to tell where is the focus. To make things worse, this depends on not only the opaqueness, but the displayed contents as well. However, if the windows are too transparent, you can’t read from them, which is bad in a single monitor setup, but totally defeats having multiple monitors.

I have tried many different arrangements and spent incredibly long time to find the perfect wallpaper hoping that it will make everything much better, but finally, I reverted to the bordered windows, but using smartBorders instead of simple borders. This solved my original problem because smart border does not appear until there are two or more windows present.

Swing applications from hell

The only problem I couldn’t figure out yet is that for some reason xmonad requires a special setting to display Java Swing applications correctly. I don’t know why it is necessary or why it isn’t an issue in other desktop environments. It’s a bit annoying, because this setting turns Chrome’s tab bar a bit bigger. Because I rarely use Swing based applications I keep this setting in a commented form in my configuration.

Conclusion

At first xmonad may seem oversimplified and hostile, but it’s quite the opposite. On top of that, it’s extremely reliable and performant. I’ve been using xmonad at home and at work, both desktop and laptop, and I’ve never encountered strange crashes.

I think it’s important to continuously watch and improve our workflows, and from the experience of the previous year, I think xmonad can be easily bent to one’s personal needs. If some frequent task bothers you or involves too much manual work, there is a great chance that it can be automated or greatly simplified.

Starting with xmonad doesn’t mean you should ditch our loved tools. I am using many excellent tools from the KDE ecosystem, like Dolphin, Konsole or Krita, and xmonad plays nicely with them.

24 August 2016

Interesting article?

Get hand-crafted emails on new content!