I’ve been a fan of tiling window managers ever since Windows 3.1. I know, Windows 3.1 wasn’t very good for much actual work, but it did stacking and tiling windows rather nicely. The i3 tiling window manager is a nice modern tiling window manager for GNU/Linux and BSD operating systems. It supports tiling, stacking, tabs, virtual desktops, and multiple monitors. You can do almost everything from the keyboard, or mix up keyboard and mouse.
You can download source tarballs or snag the latest code from the i3 git repository, but the easiest method is to install it from your distro repositories. On Debian/Ubuntu you have the i3 metapackage, and the individual i3-wm (window manager), i3-wm-dbg (debugging symbols), i3lock (screenlocker), and i3status (system status bar) packages. The i3 metapackage includes everything except i3-wm-dbg. The full-meal deal is a little over 2 megabytes, so you might as well go for it. In Figure 1 you can see that I have two virtual desktops, the status bar, and three windows arranged nicely. They’re not perfectly tiled because I rearranged them a bit: i3 is not dogmatic about tiling geometry and lets you have it your way.
Installation and First Tweaks
Install i3, then log out. When you log back in change your session to i3. On its first run it walks you through a simple configuration wizard. First you must decide if you want the wizard to create a ~/i3/config
file. Say yes. Then choose your mod (modifier) key, either the Win or Alt key. If you choose the Alt key you’re going to conflict with a lot of application keybindings and commands, so choose Win. This is really the Super_L key, but on many keyboards it bears the Windows logo. (Liberate your keyboard! Buy Tux keyboard stickers!)
Now you should be gazing upon a mostly blank screen. You should see a little tiny 1 in the bottom left corner, which is the first virtual desktop, and the system status bar along the bottom right. The background image is whatever has been set for your X11 root window. I’m running Kubuntu, so my base background image is the one set by the KDE4 theme. i3 does not touch the X11 root window, so you need an external app to set a background image. feh
is a nice little app for this. Install feh
, and then open ~/i3/config
and configure a background image by adding a line like this anywhere in the file:
exec --no-startup-id feh --bg-scale /path/to/picture
--no-startup-id
disables the startup notification so you don’t have an hourglass in your way for 60 seconds. --bg-scale
makes your image fill the screen, and does not preserve the aspect ratio. See man feh
for other background image settings.
How do you do all this? $mod+Return
opens your default X terminal. $mod+d
opens the system menu, dmenu
(figure 2). Start typing the application name, for example kate
or gedit
to bring up a graphical text editor, and when it’s highlighted in blue press the Return key to open it. dmenu
shows you all the command names that include the string you’re typing. It only finds commands that are in your $PATH. If you change your mind press the Esc key to close it. You can’t do anything else while dmenu
is open.
For most ~/i3/config
changes, press $mod+Shift+c
to reload the file and activate changes. If that doesn’t work then $mod+Shift+r
restarts i3, preserving your layout and open applications. To load your new background image you need to log out of i3 and log back in. $mod+Shift+e
exits i3, and then you log back in the usual way with your Linux login manager.
Set Default X terminal
If $mod+Return
doesn’t open the correct X terminal, then change this line in ~/i3/config
:
# start a terminal bindsym $mod+Return exec i3-sensible-terminal
Replace i3-sensible-terminal
with your chosen terminal, for example konsole
or gnome-terminal
, and reload ~/i3/config
.
Basic Layout Management
Every time you open an application it fills the available space. Apps are either lined up side-by-side, or stacked on top of each other. To duplicate figure 1, open an application in an empty desktop. Then open a second app. Then make the second app the active window by hovering the cursor over it. There are also multiple keyboard combinations for selecting the focus window, such as $mod+arrow key
. Press $mod+v
, then open your third app. $mod+v
stacks, and $mod+h
lines them up side-by-side.
Use your app menus to close them, or $mod+Shift+q
closes the window with focus.
You can move your windows around with $mod+Shift+arrow key
. Resize them by dragging a border with the cursor, or enter resize mode with $mod+r
, and then resize the window with focus with the arrow keys. Leave resize mode by pressing the Esc key.
$mod+f
toggles fullscreen. $mod+Shift+n
moves the window with focus to desktop n. $mod+Shift+spacebar
toggles a floating screen. This removes it from the tiles, and you can drag it around and resize it like in a non-tiling window manager.
$mod+e
toggles horizontal and vertical layout, $mod+s
stacks open windows, and $mod+w
tabs them.
Open a second virtual desktop with $mod+2
. i3 closes virtual desktops automatically when you close all the applications on them. $mod+n
navigates to an existing virtual desktop, or creates a new one. You don’t have to number them sequentially, but can use any numbers you want.
Configuration Hacks
Look in your ~/i3/config
file to see your keybindings, and the Default Keybindings section of the user manual shows you the i3 defaults. You can easily create keyboard shortcuts to launch applications, like this:
bindsym $mod+F1 exec firefox
I like to bind PulseAudio volume controls to the keyboard. I have multiple soundcards, so first I have to locate the correct one. You need some audio playing for this to work:
$ pactl list sinks | grep -A2 -B2 -i running Sink #1 State: RUNNING Name: alsa_output.usb-M_Audio_MobilePre-00-MobilePre.analog-stereo Description: M-Audio MobilePre Analog Stereo
These lines in ~/i3/config
let me control up and down volume with the Pageup/Pagedown keys, and toggle mute with the Home key:
bindsym $mod+Next exec pactl set-sink-volume 1 -- -10% bindsym $mod+Prior exec pactl set-sink-volume 1 -- +10% bindsym $mod+Home exec pactl set-sink-mute 1 -- toggle
Keynames are not always consistent on keyboards, so you can find the correct keynames with the xev
command. Run it with no options, and then press keys to see their names and keycodes. That’s how I learned to use Next and Prior for Pagedown and Pageup:
$ xev [...] KeyPress event, serial 32, synthetic NO, window 0x2c00001, root 0xa0, subw 0x0, time 24296185, (651,87), root:(1615,816), state 0x0, keycode 112 (keysym 0xff55, Prior), same_screen YES [...] KeyPress event, serial 32, synthetic NO, window 0x3a00001, root 0xa0, subw 0x0, time 25458177, (247,105), root:(1211,834), state 0x0, keycode 117 (keysym 0xff56, Next), same_screen YES,
i3 is wonderfully configurable. See man xev
, man pactl
, and the excellent and thorough i3 documentation to learn more about the myriad ways to customize i3 and make it super-fast and efficient.