Linux optimize

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.

Configuration

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:

:%s/44/43/

:%s/45/44/

:%s/46/45/

:%s/47/46/

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:

#############################################################

# DELETE THE FOLLOWING LINES TO DISABLE THE WELCOME MESSAGE #

#############################################################

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.

About

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.

11 comments
apotheon
apotheon

I received an email from the i3 maintainer: > Hi Chad! > > I just got a link to the article you wrote about i3. It's nice to see > people using and/or writing about my software :). I want to make two > comments: > > 1) Instead of using the rather cryptic 'bind' command, I would recommend > the 'bindsym' command. See the user's guide on how it works. We ship with a > default configuration using 'bind' to ensure the jkl; keys are next to each > other on all keyboard layouts. > > 2) The reason we use jkl; instead of hjkl is because jkl; are actually > your homerow when touch-typing. vi got it "wrong" because on many > terminals back then, the hjkl keys actually had the movement arrows printed > below the keys. Also, most of the keyboards had the hjkl keys in the same > place, while the ; key is ö in german layout for example. > > I would have posted the above as a comment, but the techrepublic signup > process is far too complicated and therefore not worth it :). Feel free to > post it, as I think especially the bindsym thing and maybe a reference to the > user's guide will be beneficial for all readers. I really don't know how I overlooked the bindsym command in configuration. He's right: that's a much better approach to configuration than using the bind command. I understand his reasoning for using jkl; as movement keys, but I still need to keep using hjkl in other vi-like environments, so I'll keep using an altered i3 configuration to match vi's movement keys rather than using the default i3 movement keys. I'll thank him in email as well, but I wanted to say here that I appreciate his feedback on the article, and wish I had encountered both his reasoning for the use of jkl; and the bindsym configuration command before writing the article. I probably should have sought him out and shown him a draft of the article, I suppose. edit: Check out the i3 user's guide for more about i3 configuration. another edit: I did not actually thank Michael Stapleberg (the i3 maintainer) in private email, because his mail server is rejecting my reply.

pgit
pgit

is there any chrome of any kind that can be altered?

robot682
robot682

I tried a few different tiling window managers before sticking with the Awesome Window Manager. I am very happy with it.

Sterling chip Camden
Sterling chip Camden

The Alt key is often useful in applications that use menus, so in xmonad I remapped its use of Alt to the mod4 (Windows) key. I assume there's a way to do that in i3 as well.

apotheon
apotheon

Don't get the idea that i3 is somehow deficient just because it's less intensively geeky than xmonad (written in Haskell) or dwm (requires recompiling to activate configuration changes). It is a highly functional, efficient, productivity enhancing tiling window manager. Xmonad offers the ability to make use of all the same general capabilities that i3 offers and a bit more, however, and nothing I have encountered challenges the Spartan minimalism of dwm.

apotheon
apotheon

Do you mean things like window borders and title bars? I'm not aware of any such configuration. Windows do have titlebars, but they are very minimal and provide nothing but a title and a place to click if you really want to use the mouse to switch windows within a workspace (or to drag if you set a window to "floating" mode, which can be toggled on and off using LAlt-Shift-Space). Borders are basically just a color difference a couple pixels wide or so to give you a place to click-and-drag with the mouse to change window sizes. I have yet to figure out how to eliminate these decorations entirely; I have not really tried to find out. I might look into it, and into the possibility of altering the decorations rather than simply removing them as well. At present, I'm not aware of any such configurability. Assuming you were asking what I think you were asking, that's a good question. (Otherwise, I guess I'm just babbling about something unrelated.)

apotheon
apotheon

There definitely is a way to do that, but I don't think I actually use any applications that make use of the Alt key at present. I mean . . . Firefox does by default, but with Pentadactyl that's not an issue.

pgit
pgit

I don't communicate very well sometimes. If I'm not pressed for time I tend to overwork an idea, stirring it up until muddy. I was slacking yesterday... =\ I asked for one of the reasons you mention; how to eliminate this entirely. I was impressed with the win8 demo, NO chrome anywhere, which is mitigated by the multi-touch capability. That's the way it's going into the future. BTW gnome 3 does a good job in this dept, and I am presently trying to find where I might eliminate any of the window manager's chrome, or at least shrink it to near invisibility. I bet anything you'd call "chrome" in i3 is a matter of the base programming of the executable(s). That is there's no config file it reads to determine border sizes, colors etc. Should be easy enough to tell, something like that would either be in a users home or under /etc. (

Sterling chip Camden
Sterling chip Camden

... but other X11 apps use Alt for menu navigation if you don't want to lean on the mouse. For instance, gnumeric, libreoffice, gimp, etc. Even if you use cinepaint instead of gimp, it has Alt-key shortcuts.

apotheon
apotheon

> I bet anything you'd call "chrome" in i3 is a matter of the base programming of the executable(s). That is there's no config file it reads to determine border sizes, colors etc. Should be easy enough to tell, something like that would either be in a users home or under /etc. ( So you read my mind correctly somewhere between the lines in what I wrote. Is there anything you can't do?! Plenty. For example, I have discovered that (given time and diligence) I can change someone's mind about how to vote -- but I can't prevent him from having a panicked last-minute "unconversion" that causes him to revert to his original "lesser evil" choice. That sort of thing (the ability to convince people of the Right Way To Do Things, but not to make the change of heart stick) frustrates the hell out of me. . . . but seriously, thanks for clarifying.

apotheon
apotheon

I don't use Gnumeric or LibreOffice, really, and my GIMP usage is rare enough, and requires the mouse enough for many operations, that it really isn't a problem to use the mouse instead of keyboard shortcuts. I haven't been using Cinepaint much, because of my little operating system issue. Evidently, stupid OSes that used to be pretty good don't have Cinepaint.