how-to-increase-productivity-i3
March 11, 2022
Ever felt like you are swimming in a lot of open application windows? A lot like you sometimes swim in browser tabs? This can make it hard to stay focused.
Enter the i3 window manager(i3)! It’s lightweight and easy to configure. Unlike traditional desktop environments this tiling window manager lets you arrange windows the way you want them arranged. Oh, and it’s easy to use too…
Let’s look at some of the problems of traditional desktop environments.
Context switching and why to avoid it
Context switching is shifting your focus away from one unrelated task to another. This even applies when tasks are somewhat related. Switching between open apps, conversations and your todo list it can be considered context switching.
When you are context switching you are breaking focus. I know it’s hard these days, but you should try to avoid it.
How traditional window managers get in your way
“Alt+Tab” is not efficient
Alt+Tab
is the way most people switch windows.
In most traditional window managers Alt+Tab
works like this:
- Show the user a list of opened windows
- The user will press
Tab
to scroll through said list - The user will release all keys when on the correct window
This process is a distraction. In order to accomplish switching windows you need to:
- Switch focus away from the real task
- Find the correct window
- Switch back to the task at hand
This Alt+Tab
method could drain mental energy, especially when you have a lot
of applications open.
Most task launchers are not efficient
For the most popular operating systems, lets briefly look at how you open applications. Apple OSX or MacOS has the launchpad. It’s an icon gallery, a very colorful one. But you need to concentrate very hard to find the application you want to open. Microsoft Windows has the start menu. It’s not easy to describe. It’s a list you scroll through. It has folders. It has things you can pin, some eyecandy. But it is still not easy to find the application you need. Granted, both of these have the option to type to search for the application you need. I wonder if this feature is widely used though.
Context switching with your body
It depends a bit on the profession you are in off course. But for me - a system engineer - most of the time I’m using the keyboard. With my hands over (or close to) the home row. In traditional window managers and their tool sets I would still need to use my mouse a lot. A lot of actions are just not optimized for the keyboard. It’s a physical context switch each time. It makes me lose (a very small amount) of time. Not to mention the ergonomic reasons.
Juggling with windows is not my cup of tea
It could be just taste. Or it could be because I’ve been using a tiling window manager for so long. But to me manually juggling with withdows feels very inefficient. For a few reasons:
- It feels like a chaos sometimes
- Dragging, dropping and re-sizing them is just annoying
Wasted screen space
In most conventional window managers there is a lot of wasted pixels unless you maximize everything or tile manually.
How i3 can solve the problem for you
How do you switch windows then?
Alt+Tab
is no longer part of my life. At least not for scrolling through open applications.
I’m using different ways to switch between open applications or windows:
- Selecting specific windows with a combination of keys
- Searching for a specific window using search terms
- Directional (what you see is what you get) switching of windows
Selecting specific windows with a combination of keys
The i3 scratchpad is an invisible work space. When you move a window to this work space it will be hidden. You can then recall these windows which will make them appear as a floating window on the center of your screen.
I use this in a few ways:
- Basic scratchpad usage: mostly for hiding windows
- Quickly jumping to a specific scratchpad window
- Dynamically throw windows to the scratchpad and recall them with a keystroke.
Using the i3 scratchpad
To move a window to the scratchpad,
I press Mod1-Shift-minus
. (Mod1
is the Alt
key)
For showing the scratchpad, I use Mod1-minus
which also cycles through all
the scratchpad windows.
These are i3 defaults. I really rarely use them but sometimes I will hide a window in the scratchpad that I know I won’t be using.
# move the currently focused window to the scratchpad
bindsym Mod1+Shift+minus move scratchpad
# Show the next scratchpad window or hide the focused scratchpad window.
# If there are multiple scratchpad windows, this command cycles through them.
bindsym Mod1+minus scratchpad show
Quickly jumping to a specific scratchpad window
I have a scratchpad terminal window bound to Mod1-grave
.
It’s my i3 alternative for the popular dropdown terminals like Guake.
I also have a “dropdown” browser (chromium)
bound to $mod-grave
($mod
= Mod4
= the windows key).
This way when I need to do a quick action in the terminal or a quick google search I can press the correct key combination and start doing what needs to be done.
# Show the scratchpad terminal window
for_window [instance="AlaScratch"] move scratchpad # For windows with this instance, move them to the scratchpad immediately
bindsym Mod1+grave [instance="AlaScratch"] scratchpad show
exec --no-startup-id alacritty --class AlaScratch # Start the scratchpad terminal window when i3 starts
# Show the scratchpad browser (chromium)
bindsym $mod+grave [class="Chromium-freeworld"] scratchpad show
Dynamically throw to and recall windows from the scratchpad
I really don’t like cycling through windows. So… I combine two i3 features to help me with this:
- The scratchpad
- The ability to mark windows
To move a window to the scratchpad I press $mod+Shift+{comma,period}
.
It will then be marked and I can recall that window using $mod+{comma,period}
.
# Dynamic scratchpad
bindsym $mod+Shift+comma mark "alpha", move scratchpad # Mark focused window with alpha and move to scratchpad
bindsym $mod+Shift+period mark "beta", move scratchpad
bindsym $mod+comma [con_mark="alpha"], scratchpad show # Recall window alpha
bindsym $mod+period [con_mark="beta"], scratchpad show
Searching for a specific window using search terms
Since I’m a Linux user for a while now I use workspaces very often. My workspaces aren’t named though, they are numbered 1-10. This is because I’m not a fan of too much rigidity. I like to stay a bit dynamic in my workflow.
So I create workspaces when I need them. And arrange windows within them as needed. I don’t often navigate to another workspace with the numbered key binds though.
A lot of times I just want to navigate to the workspace containing a specific window.
To do this I use rofi with it’s window modus.
It’s very simple. I press $mod-slash
which opens rofi and type (part of) the window name and press Return
to jump to it.
bindsym $mod+slash exec "rofi -show window"
Directionally (what you see is what you get) switching windows
When I’m working on a specific workspace, most of the time I use quite simple layouts. When I need to switch windows I change focus directionally.
# Set vim keys
set $up k
set $down j
set $left h
set $right l
# Change focus directionally
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right
A quick shout-out to rofi
Rofi, as I mentioned before helps me find specific windows. It doesn’t stop there however. I also use it as an application launcher. And with the help of greenclip it also acts as a frontend to my clipboard history!
# App launcher
bindsym $mod+d exec "rofi -modi drun,run -show drun"
# Show clipboard history in rofi
bindsym $mod+Shift+v exec --no-startup-id rofi -modi "clipboard:greenclip print" -show clipboard -run-command '{cmd}'
i3 is my ratpoison
No offense to ratpoison. It’s probably an interesting window manager if you never want floating windows. But for me, i3 is my ratpoison. It eliminates the need for a mouse. I combine this with keyboard friendly applications as much as possible.
In case of browsers I use the following plugins to help me with that:
Minimize manual actions with an autotile script
I3 is not an automatic tiling window manager. Instead it’s a manual tiling window manager. Right, let’s talk about that. What is the difference in how they work?
An automatic tiling window manager manages the layout(s) for you. You choose a preset layout for the workspace, and all windows contained by it will be presented accordingly. A few popular tiling window managers are:
In a manual tiling window manager you control the workspace layout. You are not limited to any preset or template. The “Using i3” section of their documentation does a wonderful job of explaining this. The short version: You have full control of how you want to split(horizontally or vertically), tab, stack or float windows and applications.
I like this behaviour because I want to be able to organize windows based on the situation.
I just use one hack or script (as seen in this blog post) that makes sure my workspaces (by default) will be contained to two columns.
exec --no-startup-id ~/.local/bin/i3_autotile
No wasted pixels
Most tiling window managers don’t waste any pixel of your screen, all screen realestate ends up being used!
Give it a try
Excited by all of this information? Go ahead and give it a try, just play with it in a virtual machine if you like. The i3 window manager is free, well-documented and easy to configure.
Maybe you have a different workflow but are interested in the concept of tiling window managers. In that case go ahead and try any of the alternatives listed in this great comparison on the Arch Linux wiki.