From time to time, I have profoundly bad ideas. One of those ideas is to change out the window manager on a Linux PC.
For many tasks (such as maintaining this blog), I keep a Lenovo ThinkPad X1 Carbon running Linux. It’s been a good little workhorse, running Ubuntu 20.04. I decided to switch my window manager to Xmonad, because I enjoy fast manipulation of my windows without needing to tell the window manager where they should live.
In principle, this should be very straightforward. In practice, it turns out that switching out your window manager causes a wide variety of seemingly-unrelated things to break. As best I understand it, this is because several basic “housekeeping” tasks of a desktop Linux environment actually route through the window manager, and when the WM goes away, the configurations that launch those tools goes with it. Here’s a short list of things that no longer “just work” when you switch off (I keep discovering more as I go):
- screen locking
- rendering the desktop (yes, if you give it no commands, the window manager just draws nothing!)
- auto-mounting of plugged-in USB storage
- layout of second monitors
- connecting second monitors
- battery indicator
- sound volume, mute, output control
- Bluetooth connections
The rest of this post will go into how to get a basic Xmonad setup done. Over the next while, I’ll fill in more information on how to get the remaining functionality back without Canonical’s default window manager in place.
I drew heavily from a beginner’s guide to Xmonad, which generally steered me in the right direction. I was able to install the relevant components with
apt-get. This got me a configuration running with Xmonad, Xmobar (to display content at the top), and Stalonetray (an icon tray, which is necessary for some X11 apps to have a place to show system status).
After finishing this config, some things worked but some took some banging on. In particular,
- Xmonad has been updated since this guide was released, and the way “docks” attach has changed. My
xmonad.shfactors this change in.
xfce4-power-managericon is black-on-black, so I thought it was missing. It was simply invisible in the default all-black color scheme of the top-bar. Switching to a dull grey helped the missing icons appear. Once I knew what the issue was, I was able to install
lxappearanceand run it to change the icon theme configuration; switching to “Ubuntu-Mono-Dark” provided an icon that was visible.
- To attempt to integrate with the sound control buttons on the ThinkPad, I pulled in “xmonad-extras,” which integrates against “Third party extensions for xmonad with wacky dependencies” (I’m leaving it as an exercise for the reader whether ‘controlling volume via keyboard’ should be considered “wacky,” but you do you). This proved more challenging than I expected because
apt-getactually knows this package as
libghc-xmonad-extras-dev, but once I found it it worked fine (though I will probably extract it for reasons I’ll get into when I drill open audio).
Put it all together and the end result so far isn’t terrible!
|I don't expect it to win any awards, but it's pretty functional|
Below are the relevant config files I have so far.