Open Source

Use i3 for tiling window manager n00bs

If you have had difficulty getting used to tiling window managers before, i3 may be the window manager for you. Chad Perrin walks you through some initial configurations.

Many long-time open source software users are familiar with the idea of using one piece of software as an introduction to certain types of software, to be discarded in favor of something "better" once the user is comfortable with a different way of doing things. The canonical example — pun intended — is the case of Linux distribution selection. Many new users of open source operating systems are gently guided to use something designed specifically with "user friendliness" in mind, including PC-BSD, PCLinuxOS, and Canonical's Ubuntu Linux. Once a user gains enough familiarity with the system to feel comfortable with the basics of how Unix-like systems work, learning a bit about command line operation and concepts of software management as well as finding favorite GUI applications that are portable across different open source OSes, the hunt may then be on for an OS that better suits the user's preferences.

Some never "graduate" from those initial introductory choices, of course, and there is usually nothing wrong with that. Some people prefer Ubuntu over vanilla Debian, for instance, or the easy setup and flashy appearance of PC-BSD over FreeBSD or even NetBSD or OpenBSD. Others, however, might move from Ubuntu to Debian, then to Arch Linux, and finally to FreeBSD. Some, in fact, take things even further and end up using something like MINIX 3 or Plan 9, for the ultimate in operating system conceptual purity at the expense of significant convenience.

My own path began with Red Hat Linux, before the Red Hat Enterprise Linux (RHEL) and Fedora bifurcation, then moved to SuSE Linux before Novell bought it, then to Debian before Ubuntu existed. While using Debian heavily for several years, I also played around with a number of other Linux distributions, including such widely varying options as MEPIS, Fedora, Slackware, custom Knoppix remasters, Gentoo, Mandrake/Mandriva (spanning the time Mandrake merged with Connectiva), and others. I also briefly touched on OpenBSD and FreeBSD, then finally made the switch from Debian to FreeBSD as my new favorite OS.

During all this time, I had similarly wide-ranging experience with GUI environments. I started with a bit of both KDE and GNOME, then stuck with KDE for a little while. From there, I moved on to IceWM even as I toyed with other options like Enlightenment, FVWM, TWM, and Fluxbox. I eventually settled on WindowMaker and used that happily for a while, though I kept exploring other options on the side like XFWM, Ratpoison, and even wmii. In time, I switched to Sawfish for a relatively short stint, and played with Enlightenment some more, but upon landing solidly within FreeBSD, I found myself thoroughly enjoying AHWM as my window manager of choice for several years. It is one of the most lightweight, stable, and efficiently usable window managers in existence, despite the fact it has not been actively maintained for years.

During all this time, I have experimented with a few tiling window managers here and there, but never quite felt at home with any of them. Part of the problem was the difficulty of their unapproachability. Once one has mastered the art of pointing and clicking, more mouse-driven interfaces with floating windows are easily picked up over time, providing a very shallow learning curve to ease the user in. With thoroughly documented interfaces that use floating windows and offer simple, straightforward keyboard shortcut management such as AHWM offers, the learning curve is nearly as shallow as with more clicky interfaces such as IceWM.

Tiling window managers are another matter entirely, and many of them are in fact designed around the assumptions that come from years of mouse-driven interfaces even though they consciously eschew easy operation via the mouse, leaving the new user feeling a bit lost and out of sorts. Finally, I stumbled upon i3 early this year.

i3 is a copyfree-licensed window manager (distributed under the terms of a BSD License) inspired in part by wmii, and offers support for some capabilities that wmii does not natively support. It also fails to implement some of the basic concepts of wmii operation, choosing to take a technically interesting approach to the operational model of the tiling window manager. The end result is that i3 has a more familiar "feel" to it for people coming from minimalistic, keyboard-driven floating window managers, while still providing a true tiling window manager experience. Configuration and use are fairly simple, though of course the fact that it is a tiling window manager will make it feel somewhat alien to many users at first. It also, by default, presents a keyboard shortcut cheat sheet for basic use as an automatically opened window when the user first fires up the GUI. The cheat sheet will continue to pop up when the window manager starts until the user changes a configuration option to stop that from happening.


Note that in all the following, I have only tested default operation and edits to the configuration file on a ThinkPad T510 at this time. If settings are different for your system, or behave differently, experimentation should provide knowledge of how to change things to suit your needs.

Familiarity with vi-like editors provides a fair bit of immediate familiarity with the way i3 works, too, making the process of picking up usage habits that work with this window manager quite easy. The only fly in that ointment is the fact that for some reason i3's defaults offset the standard movement keys for vi by one, so that instead of h,j, k, and l being the normal movement keys in i3 as in vi, by default the keys j, k, l, and ; are used instead. Modifying the configuration file, located at ~/.i3/config, can change these settings, though if you use i3's stacking functionality you would then need to move the stacking command from the h key somewhere else — perhaps to the ; key instead. If the ~/.i3/config file does not exist, i3 will use the configuration stored at /etc/i3/config instead.

To make changes to the configuration file, you should copy the /etc/i3/config file to ~/.i3/config if the latter does not already exist, and make changes to that copy. If you wish to shift the movement keys one to the left to better match vi behavior, and switch the stacking command to the semicolon key, a series of changes need to be made, altering numeric codes that represent various keys on the keyboard. For instance, to change the section labeled # Focus (Mod1+j/k/l/;), you would want to change as in this example:

bind Mod1+44 h

bind Mod1+45 j

bind Mod1+46 k

bind Mod1+47 l

After changing it, you should want it to look like this:

bind Mod1+43 h

bind Mod1+44 j

bind Mod1+45 k

bind Mod1+46 l

There are a number of different places in the file where the numbers 44, 45, 46, and 47 need to be changed to 43, 44, 45, and 46, respectively. If you use vi or Vim, this can be accomplished with relative ease using a series of substitution regular expression commands:





There is one case where a 43 should be changed to a 47, to change the # Stacking (Mod1+h) entry so that the stacking command uses the ; key instead of the h key. This should be changed:

bind Mod1+43 s

After changing it, the altered entry should look like this instead:

bind Mod1+47 s

This should be done last, and without using a file-wide substitution command like the others use. If it is done first, the 47 will be changed to a 46 along with the rest of the 47s. If it is done last using a substitution regular expression command, all your newly edited 43s will be changed along with this 43.

In i3, by default, holding down the left Alt key and pressing a number key will switch to a workspace corresponding with that number (where 0 corresponds with workspace 10). Using the Alt and Shift keys together, rather than just the Alt key, allows you to move the currently focused window to the indicated workspace. As you start getting used to using i3, it might be a good idea to move the cheatsheet window to some workspace other than the default location of Workspace 1; you will still be able to access it when you need it, but it will not clutter up your first workspace, which can probably be put to better use.

The end of the i3 config file should include something like this:




exec xmessage -file /etc/i3/welcome

Deleting that line, or just commenting it out, should prevent it from appearing when you start i3. This also gives you two hints about other things you can do:

  1. You can edit the /etc/i3/welcome file if you want to change the message presented to you upon starting this GUI environment.
  2. You can use the exec command in your i3 configuration file to launch other programs on startup.

The real problem for easy i3 usability is the numeric codes used to represent various keys on the keyboard in the configuration file. Once you get the hang of that, though, reading through the configuration file should prove an enlightening experience for figuring out how everything works.

Manpages for i3, i3-input, i3-msg, and i3-wsbar can give you more information about this window manager's capabilities. A popular tool for use with i3 is i3status, a statusline that can be used with a number of different taskbar-like accessories. In addition, i3 can make use of the dmenu launcher, which may be installed with i3 by default on your Unix-like OS of choice. On my laptop, the keybinding configured in the default configuration file for dmenu was Mod1+55, which corresponded to left Alt key plus the v key. If you are unfamiliar with dmenu, searching for information about its use online might be a good idea if you feel a need for a menu system — or simply installing a different menu tool and setting up a keybinding for it in the i3 configuration file.

When you begin to find yourself running up against the frustrations of some of i3's limitations, you may want to consider moving on to another, less n00b-friendly tiling window manager such as xmonad, wmii, or even dwm.


Chad Perrin is an IT consultant, developer, and freelance professional writer. He holds both Microsoft and CompTIA certifications and is a graduate of two IT industry trade schools.

Editor's Picks