> Nathan's notes_ Search Rice Projects Reading Root

Bspwm experiences

03 April 2015

So, I’ve been using BSPWM as my main WM for about 5 months now, after transitioning from i3, so I thought I would write about my experience.

The i3 Days

I had transitioned from openbox to i3, and was getting a hang on configuring i3 and what it meant to be running a tilingWM. I was enjoying the manual tiling experience and workspace configuration, however it felt a little limiting when it came too configuring a multihead layout. I could do it, but I could tell that I was limiting myself to the current setup I had and that things would need to be switched around and configured more if my monitor layout changed or if I wanted to change behavior. I was not a fan of how workspaces were handled, as it made multihead feel a little funky. However, I was a large fan of the focus-follows-mouse setting and layout togglability i3-wm presented itself with. The hardware layout limitation I mentioned earlier led to me maintaining two i3 config files for a brief time, one for my laptop and one for my home setup. This in combination with a want to drive ‘deeper’ led me to seek what I considered a more advanced WM.

Picking a WM

Around this time I was lurking /r/unixporn pretty hardcore, and both bspwm and herbsluftwm stood out to me in particular. I briefly considered something along the likes of dwm/swm/monsterWM, but those all felt like too large a leap. bspwm/herbsluftwm were to my understanding both configured with shell scripts! something that feels malleable and fun in my mind. I enjoy and hate scripting languages because they feel ‘finnicky’, and in my experience lead to alot of change->test->adjust->retest cycles. Overall I typically find this type of problem solving very relaxing, as you slowly work your way toward a goal over possibly many iterations. I continued looking into both WMs and asking people on IRC and reddit, trying to gauge the differences between the two accurately. It appeared to me that bspwm did more for you automatically in the way of tiling, whilst herbstluftWM required a lot more effort to get set up to ones liking. So I picked bspwm.

The First Attempts

It actually took 3 times before I fully told myself ‘Okay this is my WM now’. And what I mean by that is I would setup bspwm and try to understand exactly what was happening in the examples and configure things correctly, usually get it to start but be faced with problems(no panel, keybinds not seeming to work, general lack of understanding about how to fix problems with it on my end). One prospect that is exciting/intimidating is the panel situation - bspwm is EMWH compliant, meaning you can use it with a variety of panels(tint2, bmpanel, and many others), but the preferred one in the bspwm community seems to be lemonbar(formerly known as bar-aint-recursive). What’s special about lemonbar is that the information displayed on it is very explicity specified by the user. That is, you can have multiple scripts and programs that gather information and pipe the in a specific format to lemonbar, resulting in a look that can be very personalized.

This feeling of close involvement is evident in bspwm itself - the WM works off of system messages, using a client that it comes with(bspc) - using this client, you tell bspwm how to look and behave, and even trigger actions. This to me is a much higher degree of control that in i3. Because the commands from the bspc client can be issued from a shell script, it becomes really easy to take output about the current status of the WM and manipulate it just the way you want, which you can then use to either alter the behavior of BSPWM or send to lemonbar or do WHATEVER YOU LIKE WITH IT :D. Again, this is both very awesome and very intimidating, because if you can’t find an example of what you want to do when starting out, it can be very discouraging.

Adjusting

After the 3rd attempt to transition, it stuck. Things finally started to click(that the BSPWMRC file was a bash script, that the output of bspc was easily manipulated with grep and regex). here is an album from around that time, just starting with bar and had it running well on my laptop. I was still feeling stuck on ‘flexible’ configuration of monitors and workspaces, until I saw a config that renamed all monitors on startup in a loop. I didn’t even realize I could do that! Taking that as a base, I was able to get things to the point they are now in terms of multihead management.

Panel

After I got a basic-ish bspwmrc set, I was determined to get a decent panel setup. This proved harder than I thought it would be. There are many styles to take inspiration from on the internet. Most bar scripts I saw didn’t seem to handle multihead well though. This led to my current panel start script - taking the idea from the startup loop above, I looped through all the monitors displayed by bspwm and gather information about the current loop-monitor to explicitly set a panel’s geometry, allowing for correctly sized bars regardless of differing resolutions. Once I got that set, I used z3bra’s excellent blog post as code to gather information to pipe to lemonbar. However, I did have one problem - then the currently playing song from mpc was too long, it would overlap with the workspace indicators in the middle of the bar, but only on one monitor(different resolutions). This led to me deciding just to reduce the amount of information output from that shell script, and move the workspace indicators to the left of the panel.

When people ask for good starting firefox CSS configurations, they almost always get referred to twilys to use an example. I was a fan of the slants in his browser tabs and panel(He has quite an enjoyable style). I really wanted that slant look in my panel as well. Initially, I searched for ways to print a colored icon as a separator, and this led to me going the powerline panel route. I was pretty happy with that for awhile, but there is one very limiting factor to choosing a powerline style in your panel: the height of your panel is restricted to font height. As time went on, I wanted a different(thicker) panel setting, so I ditched the powerline and just had a straight up color transition in bar. After setting that up, I discovered a background rendering bug in lemonbar that the author was able to fix really fast. That kinda broke the veil for me that lemonbar was an opensource program that I could take and modify if I wanted too(I had never touched code outside of work/school/mine), and I still hungered for slants in my panel. So, I forked lemonbar and added slants to it, to get the style I wanted.

Soon after this, there was a thread on /r/unixporn where someone was asking why bspwm was so popular. In the comments, someone was talking about how one feature they were disappointed in bspwm not having was a tabbed layout. I saw that and thought it would be a good opportunity to test bspwm’s flexibility. At this point the title displayed in my panel was simply the current active window title. So, thinking about how I wanted this to act, I came up with title.sh, a script which outputs window title and id information about the current bspc desktop on a monitor in a bspc control --subscribe fashion. I still wanted only the active window title displayed if I was in tiling mode or focused on a floating window. bspwm’s other window mode, monocle, consists of the active window taking up the full desktop space, with other windows not visible. If a monitor was in monocle mode, I had title.sh spit out pairs of window titles and window IDs - which I then parse in a separate script to produce clickable title links to their associated IDs in lemonbar. This is probably the most unique thing about my setup.

Aftermath

Once things were to a point where it felt pleasant to be using bspwm, configuration effort went into cleaning up the scripts and trying to modularize as much as possible. I really like the ability to toggle different options and reload them at will, so I have all the bar display options in one ‘profile’ shell script which all the other panel scripts reference. The bspwmrc is at a point where options are organized and labeled, and you can run the script again to reload settings and reset desktops. Now configuration can go into refining WM options until I hit the sweet spot of key combinations and window manipulation options that I like.

tl;dr you get out of it what you put into it