i3 tips ‘n’ tricks

It’s been almost one year since I started using i3, completely replacing KDE and any other stacking WM/DE I was fancying to experiment with. Tiling has become my way, that’s it: easy, fast, straightforward.

If you don’t know what i3 and tiling WM is all about, you might want to head to its home page and detailed documentation, to my “first contact” post (in Italian, here) or to Simone’s “SMLB” post (dead link – removed) (if you are an Arch user).

From then on, what you need to look for is a bunch of tips on how to shape your configuration files (~/.i3/config and i3status.conf) to perfectly suit your needs. I have been building my collection from these sources:

Variables: the quick way to tinker

You’ll be likely changing things around for a while before you settle on a configuration you like. And even then, you’ll always be tempted to adjust that small detail or try out new ideas, just because it’s easy to do.

A word of advice: don’t leave junk in the config files. Move “experimental” or alternative settings to separate files instead of leaving them inside converted into comments (‘#’). The main config file is a big blob of text and should be kept as clean as possible: thus it will also be easier to search and replace the desired settings. [/grandma mode off]

Take your time to set all the variables you might need in the config file (i3status.conf will not be affected, though), that is all those parameters you’ll change more frequently.

Colors are a good example:

###- Variables -###
# Colors - Base16
set $green #90A959
set $lblue #6A9FB5

and so are workspace names, whether you just use numbers or some convoluted naming scheme full of Unicode glyphs (ehm… no… not me, really…):

# Workspaces #
set $wp1 "1: My_first_cool_workspace"
set $wp2 "2: My_other_cool_workspace"

Doing so will save you time and typos when rewriting large blocks of text every time and won’t leave you with an unchanged value somewhere in the config file.

All the statements including variables will therefore remain untouched while you look for the right shade of color

#Window Decorations Colors
#class                    border    backgr.    text    indicator
client.focused            $lbue    $green    $white    $red

or try dozens of different workspace names but still safely reach your intended target

# switch to workspace
bindsym $mod+1 workspace $wp1
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number $wp1
# Assign applications to specific workspaces
assign [class="Iceweasel"] $wp1

Reference: i3 Userguide – Variables

Move, move, move, quick!

Combine or swap modifier keys to get different “stepping” of a single action:

# Window Movement
bindsym $mod+Shift+Left move left
# Quick Window movement
bindsym $mod+Ctrl+Left move left 40px

Here, for example, I have set two similar keybindings to achieve fine (slower) and coarse (quicker) window movement, the latter allowing me to quickly move a floating window across the whole screen.

I did the same for resize

bindsym Left resize shrink width 5 px or 5 ppt
bindsym Ctrl+Left resize shrink width 15 px or 15 ppt

and volume

bindsym XF86AudioLowerVolume exec --no-startup-id amixer -q set Master 1%- unmute && killall -SIGUSR1 i3status
bindsym Shift+XF86AudioLowerVolume exec --no-startup-id amixer -q set Master 10%- unmute && killall -SIGUSR1 i3status

Reference: i3 Userguide – Focusing/moving_containers

i3 Userguide – Resizing

Mode “mode”: ON!

Keys are never enough to set all the keybindings you need and that’s where modes come in handy. The resize mode in the default config provides good hints. “Inside” a mode keys can be recycled, that is you can bind an action to a key even though it is already used “outside” (in the default mode). A basic application launcher might be a clever use of modes:

mode "App launch" {
bindsym p exec pcmanfm
bindsym f exec firefox
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+l mode "App launch"

Don’t forget the ‘mode "default"‘ statements otherwise you’ll be stuck into the mode: find the way to run ‘i3-msg restart‘ in a terminal or dmenu to forcefully get out of trouble. If the command executed in the mode doesn’t have to be issued repeatedly it might be convenient to add the ‘mode "default"‘ statement chained to the command itself:

bindsym p exec pcmanfm; mode "default"

If you are launching an application this will save you the additional keybinding to leave the mode; on the other hand, while resizing you’ll probably need a few taps before leaving the mode and you’d rather leave the return to default mode separated from the executed action. (Thanks to tasinet for pointing this out in the comments)

And speaking of modes…

Make the best of multi-monitor

Two- (or more!) screen setups seems to be quite common among tiling WMs users and such an amount of pixels must be taken under strict control: i3 is great at it! A function that seems overlooked in the Guide is the workspace movement: if you are using a laptop with an external (larger) screen attached you’ll find this useful.

mode "Move workspace" {
#Move current workspace to different output
bindsym Left move workspace to output left
bindsym Escape mode "default"
bindsym $mod+m mode "Move workspace"

With a permanent multi-monitor layout, it’s also convenient to assign workspaces to outputs to avoid “race conditions” that would result in workspaces created on outputs only according to their activation time.

From the User Guide:

workspace 5 output VGA1
workspace "2: vim" output VGA1

Combine this with assignments of application to workspaces (see the “Variables” section above) and you’ll always automatically watch movies on the big screen.

Reference: i3 Userguide – Changing named workspaces /Moving to workspaces

i3 Userguide – Assign workspace to output

 Hacking the nagbar (sort of…)

i3-nagbar is meant to show messages you can’t ignore (that’s the “nag” part): it is invoked when closing i3 (orange) and when configuration files contain errors (red). Basically it provides user-defined “action buttons” we might use for several different tasks (I’ll list a few here):

  • (yet another) launcher for a small group of frequently used application
  • reminder to perform system maintenance actions (updates, cache cleaning, …), possibly cron‘d
  • shortcut to view/edit specific files (example shown below)
bindsym $mod+l exec "i3-nagbar -t warning -m 'Edit system files' -b 'config' 'exec mousepad ~/.i3/config' -b 'i3status' 'exec mousepad ~/.i3/config'"

A quick look at the man page explains the trick: “-t ” is the message type (warning/orange or error/red, we’ll likely use the first one), “-m ” is the message at the beginning, each queued “-b '' ''” creates a button linked to the intended action (the “X” button to close the bar is drawn by default).


Well, not meant for this but still…

The only downside of i3-nagbar is that it is only mouse-driven: no keyboard shortcuts to select/activate buttons and close it (that’s still the “nag” part).

Miscellaneous tips


If you want to display fancy symbols along with plain text in i3bar, something like FontAwesome or stlarch is required. I recently realized (I have come across a snippet of dwm source code addressing the same feature) that the order in which fonts are “declared” for use in i3bar actually matters.

The first font in the list shall be the one containing icons (FontAwesome, for example), the latter the one for plain text (I use Terminus). Here is the proof:


font pango:FontAwesome 10, Terminus 10

provides the intended appearance (symbols from FontAwesome, plain text from Terminus)



while the similar statement

font pango:Terminus 10, FontAwesome 10

results in the wrong appearance (no symbols found in Terminus, falling back to FontAwesome for symbols and plain text)


No good!

Reference: i3 Userguide – Fonts

Forget vim-style bindings

Window movement is by default bound to arrows and to “jkl;” keys, that some users might be familiar with. I am not one of those and I also prefer to reuse the letters for actions/commands (l for “lock” or “launch”, for example). I guess the hours spent gaming play a role in my muscular memory to use arrows. (Again, thanks to tasinet who reported the correct “jkl;” keys instead of “hjkl”)

So, here we are at last! It took me a while to figure out some details in i3 configuration but now I am pretty satisfied with the results. What? A screenshot you say? Well, you know, I am still refining a couple of things so you’ll all have to be patient until… maybe next post on i3? 😀

Informazioni su Man from Mars


  1. juhan

    Finisce nella mia rassegna; anzi fatto.

    Mi piace

  2. Pingback: Mastering i3 | ~Smlb

  3. Pingback: Visto nel Web – 158 | Ok, panico

  4. tasinet@gmail.com

    “Window movement is by default bound to arrows and to “hjkl” keys,”

    Just for the sake of being pedantic, it is “jkl;” by default, rather than “hjkl”.

    If you aren’t going to use these, I highly recommend reclaiming them 🙂 4 free default-mode bindings are going to become rare, if they haven’t already!

    Also – when designing a mode, I find it very useful to consider if it will usually be a one-op mode or multiple-op mode. If it will usually be a one-op mode (such as your app launcher) I prefer suffixing the commands with `; mode “default” ` so that I don’t have to escape the mode manually.

    Another nice-to-have in modes is to have two definitions – one for the keybinding in and of itself, and another with the same modifier key you use to get into the mode (so you can do either PRESS_ALT->”x”->RELEASE_ALT->”z”, or by releasing at the end). Finally I usually bind the mode-entering key to also be mode-leave ($mod+r twice goes into resize mode, then back out). I love me some well thought modes!

    Finally, regarding i3-nagbar, I was kinda shocked to discover that there is no keyboard friendly way to get to it.
    You can easily replace i3-nagbar with dmenu. Here’s the a dmenu version of the exit i3 confirmation:

    [ $(echo -e ‘Oops\nQuit’ | dmenu -sb ‘#ff6600’ -fn \
    ‘-*-*-*-*-*-*-20-*-*-*-*-*-*-*’ -i -p “Better to have saved than lost”) = “Quit” ] && i3-msg exit

    Mi piace

    • Thanks for your comment and remarks, I fixed the post.
      (hjkl/;) You’re absolutely right: the default config (/etc/i3/config) binds movemements as you write. On my Italian keyboard I have the “;” below the home row, so the default bindings are anyway uncomfortable to me. Fixed.
      As written, I do remove those bindings to reuse them and stick with arrows.
      Modes I realized the same thing after publication and edited my config accordingly (added ‘; mode “default”‘ where needed) but I forgot to update the post. I guess now I have to!
      Using the same keybinding to enter and leave the mode is also a nice tip!
      Instead, I didn’t understand the whole «PRESS_ALT->”x”->RELEASE_ALT->”z”» thing: could you elaborate a little more and maybe post the relevant config excerpt? What can you do (or do more easily maybe) in the way you describe?
      nagbar “Sad but true” but it’s done this way by design (again, it’s meant to “nag” the user, not to be dismissed easily). The question and answer from the developer himself is in the FAQ, if you mind looking for it.
      The dmenu trick is also another nice tip!
      Thanks again.

      Mi piace

  5. tasinet@gmail.com

    Hi, sorry, I missed your reply.

    What I meant by the PRESS_ALT/RELEASE_ALT thing is that I always enter two definitions for my in-mode key bindings: one bound to $mod+WHATEVER pressed, and one to just WHATEVER.

    This will lead to some duplication in your configs (you need one bindsym command per binding), but if you use a nice editor, you should be able to edit two lines at the same time without problem.

    This allows me to be lazy and keep the $mod key pressed, or not, while in a mode.

    Mi piace

Dimmi che ne pensi o fai "Ciao ciao!" con la manina // Share your thoughts or just say "Hello!"

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: