Notes on seeking wisdom and crafting software

Ratpoison to i3

I’ve been an happy user of ratpoison for a good part of the past decade. Truth be told, I sinned once in between tempted by musca (a ratpoison like window manager). And today is the first day where I felt the need for a EWMH compliance from my beloved anti rodent window manager ;)

Well, like all great ideas, this one too had it’s origins in boredom! It started with the thought of tracking productivity using the windows active on a screen for a given time period. Say the productivity is absolutely awesome if it’s vim or tmux where I spent most of the time, and everything goes for a toss if I spent the hour in a browser. This metric will require dumping the list of active windows at a time snapshot. wmctrl is a tool to dump this data for EWMH compliant window managers. And our first obstacle is that ratpoison doesn’t comply with EWMH.

I started the search for a lightweight and fast replacement for ratpoison which supports:

  • Tiling
  • Keyboard driven (for most part)
  • Workspaces
  • Multiple monitors
  • Minimalist (lightweight and fast)
  • Configurable (to the windows, borders what not)

Search engines and a comparison website (I think it’s slant.co) pointed to i3. I was sold on the first few lines of description!

Do What I Mean. Good Docs. Clean Code. Sounds good?

Implement different modes, like in vim. You can use different keybindings when in the ‘resize’ mode than when you are in the default mode, for example.

The usual elitism amongst minimal window managers: Don’t be bloated, don’t be fancy (simple borders are the most decoration we want to have).

Let’s try it out! My goal is to convert the ratpoison config to a working i3 configuration. For the impatient, the completed i3 config is here.

$ sudo pacman -S i3

Thus started the journey. I installed the entire i3 package group. Wasn’t sure about i3blocks and i3status yet, but anyways.

Then I added an exec i3 to ~/.xinitrc. And startx greeted me with a welcome from i3. I went with the prompt to create a default configuration file in ~/.config/i3/config.

Edit-experiment-analyze cycle

As with other new stuff, this activity will involve bunch of experimentation. The other alternative is reading docs carefully. We prefer the first one. So here’s how the loop looks like:

# On launch i3, you are asked the Mod key
# Press Mod+Enter to open a shell
# Load up the config with vim

# Start experimenting by changing one by one settings
# Save the file

# Press Mod+Shift+c to reload the configuration
# See if the changes have effect

I started migrating the easy settings first. Multimedia keys ;) It was quite straight forward, replace bind with bindsym. Well i3 doesn’t exactly have root keybindings concept like ratpoison. Think bindsym to bind everything to the top key.

# Ratpoison binding
definekey top XF86AudioRaiseVolume exec ~/bin/voltun -c up -i 3% -m Master

# i3 binding
bindsym XF86AudioRaiseVolume exec ~/bin/voltun -c up -i 3% -m Master

That was easy. Next up is the application shortcuts. Here i3 has a beautiful concept of modes, similar to how vim modes work, except that the number of modes are unlimited. I found it the closest to the keymaps feature of ratpoison.

# Ratpoison binding
bind e exec gvim

# i3 binding
mode "apps" {
    bindsym e exec gvim
}
bindsym $mod+o mode "apps"

It works very neatly. Once you press $mod+o, the apps mode starts, next keypress determines an action. e starts gvim. All application shortcuts are now cleanly grouped.

Next up was the dmenu integration. It came out of the box with i3 on $mod+d key binding.

Managing windows

At this point, I could already go into workspaces with Mod+1, Mod+2 etc.. I tried creating multiple windows in the same workspaces. The default behavior just creates a split pane with the new app window.

Then I pressed Mod+s. The result blew me away! The windows were niftly stacked. And press Mod+j to move down the stack. Press Mod+w for some more magic :)

Extremely elegant. Here’s the relevant key bindings:

# i3 bindings
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right

Without the borders

i3 comes with nice blue borders around the windows. Few people like yours truly find it waste of real estate. So here’s to the one without borders:

# Ratpoison setting
## Set the border width for all windows.
set border 0
set padding 0 0 0 0

# i3 setting
# Do not use borders for windows or floats
new_window none
new_float none

To bar or not to

The decision to have a bar with all kinds of nitty gritty displayed on screen was a tough one for me. It takes up screen real estate and shows some random data which I don’t care to see all the time.

Nevertheless, I found few features of the stock i3bar interesting. E.g. the workspaces integration, the urgency notification etc.. I was about to cross out this idea until…

The idea to show currenly active window on the bar showed up! After an attempt to show that with i3status, I moved to polybar. My configuration for polybar is available here.

In conclusion, yours truly is now a happily converted i3 user! And the obligatory screenshot goes here…

screenshot of i3 and polybar

Namaste for now, we will talk more about the productivity experiment next time.