Switching between layouts in i3

Following my previous post on how to define, save and restore layouts, in this post I’ll show you a way to quickly switch between layouts.

As shown in the last post not only is it possible to load a desired workspace layout, but also you can automatically populate the placeholders with applications of your choice. Imagine you’ve created two layouts: workspace_1-basic.json and workspace_1-generic.json.

You can create two short scripts to load the layouts and populate them with programs. Please note that we need to kill all the existing windows in the workspace. Otherwise, the loaded layout will append itself next to the existing windows on the workspace. It’s not the most graceful way of killing windows but I couldn’t find any other way of doing it. Furthermore, do not forget to add the trailing & to indicate that the job needs to be executed in the background. Otherwise, the first program will block loading any subsequent ones.


# Kill all the existing containers
# Add more instances of the 'focus parent' command if you ever have more containers
i3-msg 'workspace 1; focus parent; focus parent; focus parent; focus parent; focus parent; kill'
i3-msg 'workspace 1; append_layout /home/sycamorex/.i3/workspace_1-basic.json'

# Start programs
xterm -name topleft -e 'ncmpcpp' &
xterm -name bottomleft &
xterm -name topright -e 'emacs -nw' &
xterm -name bottomright &


# Kill all the existing containers
# Add more instances of the 'focus parent' command if you ever have more containers
i3-msg 'workspace 1; focus parent; focus parent; focus parent; focus parent; focus parent; focus parent; kill'
i3-msg 'workspace 1; append_layout /home/sycamorex/.i3/workspace_1-generic.json'

# start programs
xterm -name topleft -e 'ncmpcpp' &
xterm -name middleleft -e 'irssi' &
xterm -name bottomleft -e 'mc' &
xterm -name topright -e 'htop' &
xterm -name bottomright -e 'emacs -nw'

We can bind them to keys in i3 main config file:

bindsym $mod+g exec /home/sycamorex/.i3/i3-load-generic.sh
bindsym $mod+b exec /home/sycamorex/.i3/i3-load-basic.sh

Please note that the layout feature is still fresh. It hasn’t even reached the stable branch of i3 yet. As far as I know, it’ll be part of version 4.8 of i3 (whenever it’s released). See my previous post on how to install the development branch of i3 that will let utilise this feature.

Happy tiling!!!

i3 4.8 featuring layout saving capabilities

There are going to be some exciting changes in the next version of i3. Version 4.8 will have a new feature of saving and restoring workspace layouts.

If you’d like to try it now, you can use a development branch of i3 git repository to build a package. Here is a SlackBuild script that can be used to build the ‘next’ version of i3. Please note that you need to specify the version as follows:

VERSION=next ./i3.SlackBuild

Without passing the version, the script will build the ‘master’ branch of i3, which is the latest stable version including all the bug fixes.

Before you can build i3-next, you need to install all the dependencies. Apart from the old ones (dmenu, libev and yajl), there are some new perl modules required. They are not runtime dependencies, but they are needed if you would like to utilise the new layout features.

New dependencies:
* perl-JSON-XS (available on SlackBuilds.org)
* perl-AnyEvent-Handle (script)
* perl-AnyEvent-I3 (script)

New layout features

The new layout features allow for a quick way of saving and restoring workspace layouts alongside with all the applications populating the placeholders. Below is a tutorial on how to use this feature.
The following is a layout we will be working on:

i3 layout
First, open and appropriately arrange required programs. In my cases it’s a number of xterm instances running various command line tools. To make it easier for a further identification of a window, I start each of them with a meaningful name, such as:

xterm -name topleft

I have 5 labels, each describing the position of a container: topleft, middleleft, bottomleft, topright, bottomright.

Once you’re happy with the layout, you need to save it in a file. The layout is going to be stored in a json format.

i3-save-tree --workspace 1 > /home/sycamorex/.i3/ws_1-generic.json

By default, the file is not yet ready to be used. First, you need to edit the file to ensure each window matches the criteria to be swallowed by the right container.

If you open the JSON file containing the layout, each section representing a window will contain a ‘swallows’ subsection that will help us identify each container

  "swallows": [
   // "class": "^XTerm$",
   // "instance": "^middleleft$",
   // "title": "^middleleft$"

  "swallows": [
   // "class": "^XTerm$",
   // "instance": "^bottomleft$",
   // "title": "^mc\\ \\[sycamorex\\@darkstar\\]\\:\\~$"

There are three things to observe here: by default, the class, instance, and title variables are commented out so we need to remove the comment tags. The title of the ‘middleleft’ window has not been captured. I would like it to be populated by ncmpcpp so I’d need to modify it so the section reads

 "swallows": [
    "class": "^XTerm$",
    "instance": "^middleleft$",
    "title": "^ncmpcpp$"

After the layout is loaded, the middleleft container can be populated by ncmpcpp in xterm with the following command:

xterm -name middleleft -e 'ncmpcpp'

The last thing to note is that although sometimes the title variable will get populated (like in the bottomleft section above), it may however need some cleaning up so that it reads:

 "swallows": [
    "class": "^XTerm$",
    "instance": "^bottomleft$",
    "title": "^mc$"

If any of the variables do not match a window properties, you can always check them with the xprop tool. Now that we have cleaned the JSON file (here you can see the entire file for the example above), we need to create a script that would load the layout and fill the placeholders with programs:


  # Load the layout
  i3-msg 'workspace 1; append_layout /home/sycamorex/.i3/ws_1-generic.json'
  # Swallow the programs into the containers
  xterm -name topleft -e 'ncmpcpp' &
  xterm -name middleleft -e 'irssi' &
  xterm -name bottomleft -e 'mc' &
  xterm -name topright &
  xterm -name bottomright -e 'emacs -nw'

The first command appends the layout to workspace number one and subsequently all the containers get populated with various CLI applications.

You can now bind the script to a key so that everything can be loaded in an instant. I have added the following to my ~/.i3/config:

bindsym XF86HomePage exec /home/sycamorex/.i3/i3-load-generic.sh

Alternatively you might want to load a layout on i3 startup. In that case, please add the following line to ~/.i3/config:

exec --no-startup-id "i3-msg 'workspace 1; append_layout /home/sycamorex/.i3/ws_1-config.json'"

You could also execute particular programs on i3 start.

exec --no-startup-id /usr/bin/xterm -name topleft -e 'ncmpcpp'

I’ve however chosen not to do it automatically as I do not need a particular layout everytime I start i3. Furthermore, I’ve created a few layouts depending on what I do or need: generic, web-devel, python-devel, etc. Each profile or layout is assigned a different key making it easy to quickly load it with one key.

Thank you, Michael, for adding it to i3.

Learn how to quickly switch between layouts.

Slackware and i3

The release of Slackware 14.1 has brought a number of important changes including a switch from MySQL to MariaDB or the introduction of UEFI support. For i3 users, however, the most relevant change was the update of cairo. At the beginning of the year the changelog of Slackware’s -current branch read:

Lots of X updates in this batch! We were finally able to upgrade to the
latest cairo (including the long-requested XCB backend), as the text
corruption bug that was preventing that was fixed in the upstream X server.

This, as I have mentioned many times, means that we can now install i3 as the upstream wanted it, in its vanilla state. Today the 14.1 branch of Slackbuilds.org has officially been opened to the public including cleaned-up scripts for i3 version 4.6. Last month I contacted Michael, the author of i3, who suggested a few small changes, which have been implemented.

If you’d like to build i3 from its master git branch, have a look at You can still use my scripts for the master branch of i3, feel free to use the following script:

Happy tiling!!!

i3wm master branch script cleanup

Seeing problems as opportunities is an extremely helpful approach that has yet again proven to work well for me. Recently someone has reported problems building i3wm using my Slackbuild script that uses the i3 master git branch. Not only did it prompt me to revisit the script but also encouraged to get in touch with Michael, i3 developer, who, as usual, was extremely helpful providing me with a number of corrections and helpful comments. Additionally, I liked how another slacker organised doc files and added those modifications as well.

Below you can get a SlackBuild script for the master branch of i3wm for Slackware-current (14.1). It’s not going to build on Slackware 14.0 or older.



i3 on SlackBuilds.org

Recently I have received a number of emails pointing out that i3 version on Slackbuilds.org is rather out of date. I would like to assure you that I have not abandoned maintaining the i3 SlackBuild. I have refrained from bumping up the version on the Slackbuilds site due to the change introduced in i3 v4.5 (and described in my previous posts) that would necessitate building i3 with PANGO disabled. As this is not in the true Slackware spirit of shipping vanilla software, I thought I’d keep it that way. The good news is that the latest (4.6) version of i3 builds fine on the -current branch of Slackware. That will make it possible to update the i3 version on the SlackBuilds website once Slackware 14.1 has been released, which shouldn’t be before long. In the meantime you can build the latest i3 version from the master branch script (-current: without modifications, 14.0: with PANGO disabled).

A quick bugfix release of i3 – version 4.5.1

This release fixes, among others, a high memory consumption problem in i3 4.5. The issue, as explained by Michael, is a result of a human mistake in the release process. For full details of a bug report, see this. The new release fixes the problem, as well as, introduces a few other changes.

Feel free to use my SlackBuild script to build the latest stable release of i3 including all the bugfixes. The builds for Slackware 14 and the -current branch are available here:



i3wm 4.5 on Slackware

Having come back from my holiday I found a pleasant surprise in the form of a new i3 release which contains a lot of bug fixes and cleanups. For a list of all the changes in the new version, please refer to the release notes.

As usual, you can grab a SlackBuild for i3wm 4.5 here. As explained in my previous posts, this SlackBuild is aimed at Slackware-current and will NOT work for Slackware 14 or older.

Furthermore, regardless of the Slackware version you use, I’d like to encourage you to use SlackBuilds (Slackware14, Slackware-current) pulling the master branch of the i3 window manager. See the explanation in my previous posts.


i3 4.4 on Slackware (available for -current)

Today’s batch of updates in the -current branch of Slackware has brought some interesting changes. If you have been following this blog, you may have guessed that what was particularly interesting to me was the inclusion of cairo-1.12.14 which ships with the XCB backend enabled by default:

Fri Feb 22 01:09:25 UTC 2013
Lots of X updates in this batch! We were finally able to upgrade to the
latest cairo (including the long-requested XCB backend), as the text
corruption bug that was preventing that was fixed in the upstream X server.

This update makes it possible to build the latest version (ie. 4.4) of the i3 window manager without disabling Pango. For more details, see this post. I have updated my SlackBuilds for i3-4.4 (or to be specific the master branch, which contains the latest stable release + bug fixes). The SlackBuilds are available for downloads from here:


or from github:


Enjoy and let me know of any problems you might have. On a separate note, thank you Patrick for so many goodies in this batch of updates.

i3 4.4 on Slackware

i3wmEverybody knows that tiling window managers are the cure to all the world’s problems.

…and with the recent release of i3 v. 4.4, the world should sigh with relief. Having thoroughly inspected i3 source code, I can assure everyone that the world is NOT going to end tomorrow or any time soon.

Now that I have hopefully put your mind at rest, we can focus on the new i3 release. As I blogged a few months ago, the 4.3 introduced the pango support for rendering text which resulted in the package not compiling on the stock Slackware installation (see details). The situation has not changed with the release 4.4. At the moment of writing this, Slackbuilds.org offers i3 4.2 which is the last version that works flawlessly without any hacks. If you would, however, like to run i3 4.3+ you can either recompile the stock Slackware cairo package with enabled xcb support or disable pango support in i3. Again, I have chosen the latter option as being less intrusive on a Slackware system.

Below are my updated SlackBuilds scripts for the most recent stable version of i3. The Slackbuild is not written for any particular version of i3, such as 4.3 or 4.4. It automatically pulls the source from the ‘master’ branch of i3 git repository, which is the most recent “stable” release + any bug fixes.

i3 master branch SlackBuilds

One of the new features included in this release is i3-dmenu-desktop, a dmenu wrapper for .desktop files. The feature was discussed in one of the threads of i3 mailing list. To see the full list of changes and bug fixes, please visit 4.4 release notes.

Update: See the update to this article here.
Happy tiling!!!

dwb on Slackware

Being a big fan of lightweight and keyboard driven applications, I have always felt some kind of distrust towards bloated software that relies heavily on mouse clicks. For most tasks, using well configured keyboard shortcuts can be a much more efficient means of interacting with software. It is particularly true of command line software that I use on a daily basis. Since most of my activities involve keyboard driven interaction, it has always felt somewhat inefficient to keep switching between the ‘keyboard’ and ‘mouse’ modes, which is required when using a traditional web browser. It looks like dwb partially solves this nuisance. Edit: I say partially as it does not seem as lightweight as one would wish. As pointed out in the comments, its memory consumption is rather huge for a supposedly lightweight browser. On my system it looks similar to that of Firefox. Still, it is at least worth a try.

What is dwb?

dwb is a highly configurable WebKit web browser. It makes a heavy use of keybindings and employs vi-like modes (normal/insert/hint/command modes). Not only does it provide you with a great number of commands and settings, but also it lets you create custom commands as well as userscripts (via an available javascript API).

Install dwb on Slackware 14

Full Slackware 14 install provides you with most of the required dependencies with the exception of webkitgtk. Once you’ve installed webkitgtk, you can use a SlackBuild script that I have writen to install dwb on Slackware 14. The script (as well as a precompiled package for Slackware64) is available here:

dwb Slackbuild script and package downloads

Please make yourself familiar with dwb documentation before you start using it.

Happy browsing.