id="info"

How to customise your Linux desktop: i3 Window Manager

The i3 Window Manager is an extremely lightweight, fast, text-oriented alternative to the other Desktop Environments and Window Managers I have discussed so far.

Until now in this series I have discussed most of the common Linux desktop environments (Xfce, KDE, Gnome 3, Cinnamon, MATE and LXDE), and a couple of Window Managers (OpenBox and Enlightenment). Now I am going well off the beaten path to look at something completely different: the i3 Window Manager.

I think that it is important to start by saying very clearly that i3 is not intended for beginning, inexperienced, average, or even 'normal' Linux users. Yes, that means exactly what it says -- the vast majority of Linux users are not going to find i3 useful, or even very interesting.

Experienced Linux users should look at what i3 does, and how it works, and decide if it suits their needs. That last statement is important -- it is not possible, or at least not sensible, to try to customize i3 so that it can be used as a general-purpose desktop environment. Attempting to do so will almost certainly end up sending you screaming into the night.

So what is i3, then, and who is it intended for? It is a window manager, in the most pure and simple sense of that term. Here is what the Manjaro 15.12 i3 distribution looks like on first boot.

Manjaro i3

Manjaro Linux 15.12 i3 Distribution

Photo: J.A. Watson

At first glance that doesn't look too scary. It's different, certainly, but it has something that looks sort of like a Panel across the bottom of the screen, and some status and other information included in the wallpaper. Hang on to that 'not so different/not so scary' feeling, because I suspect it is going to get pretty well shaken up before you really start to feel more comfortable with i3.

i3 is not a desktop environment in the sense of things like KDE and Gnome, or even the lightweight Xfce and LXDE. One of the simplest ways that I can think of to explain the difference is that while most desktop environments are concerned with eye candy, i3 is much more concerned with finger food.

Here's another way to explain it. i3 is a text-oriented (and keyboard-oriented) window manager, where the other traditional desktops are graphic-oriented (and mouse-oriented) systems. That doesn't mean that i3 doesn't use the mouse, of course. When we get to managing multiple windows later, it will be possible to select windows with mouse-clicks. But in i3 what is important is that you can easily manipulate windows without the mouse, using only the keyboard. In fact, this is such an important objective for i3 that the developers and users are pleased and proud when they can say, 'I did xxxxx (whatever) without even touching the mouse'.

Perhaps it is better to give an example of who i3 is intended for, rather than who it is not. My day job is in network security engineering. My colleagues and I spend a lot of time dealing with text-console devices and CLI commands, and we are usually dealing with more than one device at a time - often a lot more than one. So having a window manager which makes it fast (very fast) and easy to create new windows, and manage existing windows without taking our hands away from the keyboard is a big advantage. Did I mention fast? Good.

OK, so how do you use i3? I'm going to walk through some examples to show the first few simple steps of opening and managing windows.

I think that the single most important concept in i3 is the Modifier key, which I will refer to in the rest of this post as Mod-. This is the key you press and hold together with other keys to perform basic actions such as opening new windows or moving between windows. This is likely to be either the Alt key or the Super key (aka Window key) on most installations and keyboards - in Manjaro i3 it is Super by default.

2016-01-06-1232431366x768scrot.png

Let's take the first leap, and open a window on i3. One of the simplest is a terminal window, which can be opened by pressing Mod-Enter.

Yikes! What is that? It looks like i3 has opened a full-screen terminal emulator, with the shell prompt at the top left corner of the screen, and the translucent body of the window covering the rest of the display. But it's so... naked! It looks like i3 has turned my nice graphical display into a VT-100 terminal!

Ok, keep calm, breathe. There are no borders, window frame, buttons, controls, omg, what am I going to do with this?

What if I run a command or something, and produce some output in that window? I can run top, for example, which produces a lot of output and continually refreshes, so the result will be very obvious.

2016-01-06-1242281366x768scrot.png

This shows that our first impression was correct - there is a translucent terminal window covering the entire screen, so the contents of that window are displayed over the text (and graphics) of the wallpaper. Gulp. But still no eye candy, no decoration or controls.

If your only experience until now has been with traditional GUI desktop managers (KDE, Gnome, Windows, Mac), this is probably looking pretty scary (or maybe pretty useless).

The good news at this point is that in my experience, this is a scary as it gets. Hang tough, things are gong to get better soon.

There is one very simple concept here, and as soon as you really grasp it, and accept it, the task of learning i3 becomes a lot easier - not to mention a lot more logical and even a bit of fun. The concept is that i3 is a window manager. That's all. It's task is to fill the entire surface of your display with whatever windows you create. Period. It doesn't decorate them, add controls to them, stack them, or do anything else to them. It just figures out how to cover your desktop with them.

In this case, we currently have only one window so it covers the entire desktop. It doesn't have a border, it doesn't have a title, it doesn't have controls or buttons to minimize/maximize/iconify, it is just a bare-bones window with a terminal emulator running inside. That is what i3 is here to do, so - mission accomplished.

Ok, that's fine for one window, but what if there is more than one? Well, let's try it by simply pressing Mod-Enter again. That will open another terminal window.

2016-01-06-1303261366x768scrot.png

Exactly what happens at this point will depend on the size and shape of your screen. A second terminal window will be created, and the screen will be split so that each terminal window gets half of the screen. Whether that split is vertical or horizontal depends on the dimensions of your screen, but the result is conceptually the same either way. I am working on a wide-screen display (1366x768), so the split was vertical, and now I have the original window (still running top), and a new window right beside it with a shell prompt waiting for input.

2016-01-06-1318311366x768scrot.png

There's even a little bit of good news in the eye candy department, because now there is a very narrow border highlighting the active window.

Getting back to the concept that I started above, i3 is a tiling window manager. This means that it will arrange whatever windows you have open so that they are all entirely visible at all times, and together they entirely cover your display. Think of it as being like a tiled floor - all of the tiles are arranged side-by-side in two dimensions. The alternative, as is implemented in the window managers for almost all of the common Linux desktops, is a stacking window manager, where windows can overlap and even completely cover each other. That doesn't make sense for tiles on your floor, and i3 says that it doesn't make sense for tiles on your display.

So we have already learned one i3 keyboard command - Mod-Enter to open a terminal window - and now that we have two of them, we get to learn another one, because having two windows isn't much use or fun if you can't move between them.

Now, you could move with the mouse... but as I said above, for most i3 users one of the primary goals is not to have to take your hands off the keyboard. So the "preferred" way is to use the Mod- key together with the arrow keys. If your screen is split vertically, as mine is, then Mod-LeftArrow and Mod-RightArrow moves between them. If your screen split horizontally, then use Mod-UpArrow and Mod-DownArrow.

For most people, having two terminal windows is not terribly exciting. In fact it is considered to be so boring that the Gnome 3 developers actually made it a pain to open two of the same window. (Bleah to them.) So for purposes of illustration I am going to close one of the terminal windows - the remaining window will immediately expand to fill the screen - and then open something else.

That sounds slightly easier than it is, because so far we don't know how to start 'something else' - or anything else, we only know Mod-Enter to start a terminal. So now we need an application launcher, and in i3 it is called dmenu. It's not the kind of category/cascading menu that we are used to in the other desktops, this is an input-sensitive menu. When you press Mod-d i3 will open a launcher/menu bar across the top of the screen, like this:

2016-01-06-1348441366x768scrot.png

The i3 dmenu launcher

Photo: J.A. Watson

The input area at the left end is where you can type the name of whatever you want to run; the rest of the bar across the top of the screen displays a list of the executable objects that match your input. It's sort of like having a dynamically updated version of the shell <tab> function.

I want to run the i3 file manager, which is called 'ranger', so I start typing that, and with each letter the display of available programs is refined. When the name 'ranger' is highlighted, I can press return to run it. Very nice.

2016-01-06-1411481366x768scrot.png

That once again splits the screen in half, with the original terminal window on one half and a new window for the file manager on the other half, as shown here.

OK, I think this is going great so far. We can open windows, use the dmenu launcher, and move between multiple open windows. Before going on, I need to explain some terminology.

What I have shown so far when I have multiple windows, where they are arraged side-by-side on the display, is called horizontal tiling, because the windows are arranged in a horizontal row. The alternative, shown only once above, is vertical tiling, where windows are arranged above/below each other, in a vertical stack.

I said above that the way windows are tiled depends on the dimensions of your screen, and that is true, at least by default. But you can override that with keyboard commands - Mod-v for vertical tiling and Mod-h for horizontal tiling. So if you start from an empty screen, when you press Mod-v you will see a little message window at the top left of the screen that says tile vertically. If you then open two windows, they will be stacked on top of each other, if you press Mod-h and then open windows, they will be arranged side-by-side.

This tiling behavior attribute is not global in i3, it is specific to each object, and it is inherited by the children of each object. To illustrate this, I'm going back to the screen where I had a terminal and a file manager side-by-side (horizontally tiled) on the screen. With focus on the file manager (right window), I press Mod-v, and then I open another window.

2016-01-06-1502251366x768scrot.png

Here you can see that when I started the gpicview application (an image viewer), i3 used vertical tiling, placing the new window below the existing window, which was reduced by half.

If I were to create yet another new window while focus was still on either of these two vertically tiled windows, it would also be vertically tiled with them. So the result would be three windows in the vertical stack.

2016-01-06-1509471366x768scrot.png

However, I have not changed the tiling mode for the original terminal window, which still occupies the left half of the display. If I change focus to that window (using either Mod-LeftArrow or the mouse) and then open a new terminal window, it will still be created with horizontal tiling - so I will then have two very skinny terminal windows.

This splitting of screen space to make room for new windows can be repeated as much as you like, but of course it doesn't take long for the windows to become too small to use effectively. To solve this problem, i3 makes it very easy to use workspaces.

i3-workspaces.png

The way that i3 deals with workspaces is very flexible and very powerful. When i3 first starts up it uses workspace 1, as indicated by the small box at the bottom left corner of the screen. To change to another workspace you simply have to press Mod-<n> where n is the number of the workspace, from 1-8.

Workspaces are created (and destroyed) on demand by i3, so when your screen becomes cluttered (or if you just want to organize your windows in logical/functional groups) you can hit Mod-2 (or your favorite/lucky number if you're superstitious) and you instantly get a clean new screen to use. A second box with the number of the new workspace is added to the bottom left corner of the screen.

You can then create windows and work with the new workspace in exactly the same way as the original workspace. Switching between workspaces can be done via the keyboard with the Mod-<n> command again, or via the mouse by clicking on the numbered boxes at the bottom left corner of the screen.

It is important to understand that i3 does not keep unused workspaces sitting idle; if you leave a workspace which has no open window, it will be closed and its number will be removed from the workspace list boxes. You can still use the keyboard to return to that workspace, and it will be there again and ready to run new windows.

Besides the obvious situation of too many windows / too little screen space, workspaces are an excellent way to group windows for quick, logical access. One common grouping is to have one workspace for work-related windows, one for Internet access (browsing, email, etc.), and one for recreation, games and leisure activity.

There are many other possibilities for workspaces. Grouping by device type (routers on one workspace, firewalls on another and so on), or when working with several devices of the same type then using a different workspace for each device.

The point here is that when workspaces are so easy to create, and switching between them is so simple and fast, they really become a natural and important part of your environment. I hope that you are beginning to see how using a tiling window manager, which keeps all of your windows open and entirely visible rather than stacking, overlapping or completely iconifying them, can be a real advantage.

That's enough for this post, I think. In the next post I will look more into the normal use of the i3 window manager. Until now I have only looked at a couple of simple utilities and applications, so I will show how to install and use a few of the more common programs, such as a web browser.

Read more on Linux and open source:

Newsletters

You have been successfully signed up. To sign up for more newsletters or to manage your account, visit the Newsletter Subscription Center.
Subscription failed.
See All
See All