Monday, August 5, 2019

How I fell in love with i3

Understand what i3 is and how it can drastically change how you use your Linux desktop.

I've been using the i3 window manager for almost a year and would like to share some thoughts about it. But first let's understand what i3 is and how it can drastically change how you use your Linux desktop.

What is i3?

The official documentation describes i3 as:
a tiling window manager, completely written from scratch. The target platforms are GNU/Linux and BSD operating systems, our code is Free and Open Source Software (FOSS) under the BSD license. i3 is primarily targeted at advanced users and developers.

But what's a tiling window manager?

Tiling Window Managers

A tiling window manager is a program that runs on top of your operating system's (MacOS, Windows, Ubuntu, etc) graphical user interface (GUI) that auto-manages your windows for you. For reference, the most common way users to use computers these days is via desktop mangers (Windows, MacOS, Gnome, KDE, etc). That same program that sets your desktop wallpaper, allows you use to drag and moving windows around and interact with your running windows and services.
Source: http://orig09.deviantart.net/3f05/f/2016/177/d/9/gentoo_linux___i3_wm___by_irenicus09-da7obes.png

Differences

So what are the differences between a tiling window manager and a desktop manger?

Concisely, this is how a tiling window manager differs from a desktop manager. Tiling window managers:
  • auto-place windows on the desktop
  • automatically split window space
  • do not allow dragging or moving windows around
  • always use 100% of the allocated space
  • are easily customizable
  • allow managing desktop applications using the keyboard
  • can be configured to pre-load specific configurations

Why i3

Working with i3 may be a radical shift in how we use the desktop. So why would Linux users switch from traditional desktop environments like Gnome, KDE, MATE, Cinnamon to i3?

You should consider i3 because i3:
  • will make you more productive
  • is simple, concise
  • is lightweight
  • is fast, super fast
  • is not bloated, not fancy (but can be)
  • is extremely customizable
  • will save you time and brain powers since you will stop wasting time dragging and searching windows around
  • allows you to manage your workspace entirely using the keyboard
  • has vi-like keybindings (yes, this is a plus!!)
  • allows you to configure shortcuts the way you like
  • has easy support for vertical and horizontal splits, and parent containers. 
  • improves your battery life

A Beautiful Desktop

i3 will make your desktop beautiful. Through its simplicity you will discover a more uniform and elegant experience. For example, take a look at this beautiful Arch desktop running i3. See how all applications integrate seamlessly. No overridden windows, no pixels wasted.
Source: https://www.reddit.com/r/unixporn/comments/ahtyr4/i3_my_arch_setup/

Producivity

My productivity increased significantly using i3. Why? Because it's so keyboard friendly that I stopped using the mouse to control my UI. Yes, I still have to use the mouse to interact Firefox (and vimium, of course) but that's pretty much it. All the rest of my work can be easily accomplished via easily customized keystrokes.
Source: https://www.reddit.com/r/unixporn/comments/3hjzrh/i3lemonbar_i3_powerline/

Efficiency

You spend a lot of time dragging windows around and alt-tabbing between them. i3 saves me hundreds of alt-tabs and hand-right-hand-left movements to reach the mouse. With i3, I keep my hands focused on the home row of the keyboard. I feel less tired after a 4-hour session of work on my Fedora at home than after a 2-hour session on Windows at work.

Why? Arm right, Arm left. This (per/con/incon)sistent involuntary movement to reach the mouse adds a lot of fatigue to your body without you even noticing. It's pretty much why advanced Vim users are more productive. Why? Because Vim keybindings were designed around the home row of the keyboard.

Customization

The i3 configuration is simple to read, understand, share and modify. Don't like that keybinding? Change your ~/.config/i3/config file and do your changes. For example, here are some of the custom bindings have:
  • $mod (windows key) + enter: the terminal
  • $mod (windows key) + f: firefox
  • $mod (windows key) + shift + f: firefox private window 
  • $mod (windows key) + g: chromium
  • $mod (windows key) + shift + g: chromium private window
  • $mod (windows key) + e: file manager (similar on windows)
  • $mod (windows key) + r: resize windows
  • using multimedia buttons for calc, sound, print screen, etc.
  • remapped i3's default jkl;3; to follow Vim's hjkl key pattern

Easy to get started

i3 is available on repositories for Fedora, Ubuntu, Arch and other major distros. That said, installation should be straight forward. After you start i3 the first time, you are prompted for an initial configuration that will set the basics for you to get rolling.
After installation, you'll be prompted with this screen on your first login

Backwards Compatible

Be assured that you will still use all your GUI applications with i3. Firefox, Chromium, Calculator, Nautilus, Gnome settings or Gimp, everything should be available and accessible trough the default  dmenu.
Source: https://i3wm.org/screenshots/

Extensible

In case the defaults don't appeal to you (probably they won't), remember, you can always change. For example, it's simple to switch the defaults to:
  • change the toolbar: i3blocks or polybar
  • add padding between tiles (windows): i3-gaps
  • add fancy UI transitions with compton
  • enhance your desktop background: conky, feh
  • replace your application launcher: rofi

Extensive Documentation

The i3 official documentation is also an excellent resource and very well documented. YouTube, GitHub and the i3wm community on Reddit are also great resources to learn how to configure your installation.

Benefits

Now the important part. What do we gain using i3? In my experience i3:
  • makes my workflow more productive
  • makes me complete my tasks faster
  • make me feel less tired after a long session of work
  • reduces context switching
  • makes me learn more about the GNU/Linux operating system
  • makes me use more the terminal and terminal-based tools
  • makes my machine faster
  • made me finally switch to Vim
  • made me learn more about configuring other parts of my system

You will use more the terminal

I realized that with i3 I've been using more and more the terminal. I replaced most of the visual GUI applications with tools like:
  • system management: systemctl, dnf, journalct, etc
  • networking: nmcli, ifconfig, iwconfig, netstat, etc
  • process management: top, htop, etc
  • text editor: Vim
  • text manipulation: sed, awk, grep
  • search: fzf, find
  • file management: ranger, xargs

You may not realize but once you memorize the commands and rely less on the mouse and on graphical applications which by design are less feature-rich, you will become more confident using your system, improve and accelerate your workflow. Then you learn more and repeat the cycle.

New tools, New workflows

And because I'm using more and more the terminal, I'm changing my workflow to use tools such as:
  • mutt - so far, getting introduced to it. Man, it's been a long time since I used Pine and, it's awesome!
  • ranger - for file management. Still getting used
  • rtv - reddit client
  • w3m/lynx/links - on a SSH session
  • tmux - became essential with WSL and on a SSH session
  • fzf, fzf.vim - command line fuzzer
  • awk, grep, sed, cut - manipulate streams

Vim

Yes! That is a huge improvement and something I've been trying to do for a long time. I'm finally switched to Vim full time because Vim is awesome! Light-weight, extremely customizable, multi-platform and extremely powerful. I realized that with i3, it doesn't make sense to leave the keyboard and the terminal! Vim is an excellent companion to i3!

Vimium

In my search for reducing mouse usage, I found the amazing vimium extension for Chrome and Firefox. Man, don't know how I survived before it. I can browse the web and quickly get to the results I need by barely using the mouse. Amazing!

Better Performance, less Memory

Computational performance is like free beer, we never say no =). Gnome was already fast on my notebook but i3 makes it even faster. Add to that less memory consumption and you will see how the performance of your machine will improve! It's even better with old hardware paired with XFCE, LXDE or LXQT.

You will learn more Linux

Using i3 made me learn and know more about the Linux system and the GNU tools. Because I drastically shifted how I do my work on my Linux box to using tools such as grep, Vim, tmux, ranger and mutt. I've also stopped and finally learned how to work well with sed, awk, systemd, firewalld, networkd and lots of other system tools that I never bothered with.

Installation

So, you like what you read, let's see how to install it.

Installing on Fedora

The installation on Fedora should be:
sudo dnf install i3 i3status dmenu i3lock xbacklight feh conky

Installing on Ubuntu

sudo apt update
sudo apt install i3

Logging in

Assuming the installation was successful, logout and before logging in, remember to change the toggle to use i3:

Source: https://fedoramagazine.org/getting-started-i3-window-manager/
On your first login, you should be presented with this screen that will automatically generate a configuration for your user:

Customizations (rices)

Unless you're super minimalist, you will like customize your i3. There are a lot of tutorials out there and I urge you pick some specific for your distro. In general people add a different color scheme, change icons, fonts, the toolbar, and the Gnome theme when applicable. Some examples can seen here.

Mine is pretty much standard with some different keybindins (to make it more vim-aligned), black themes and removal of toolbars on my terminals.

Suggested Videos

I also recommend watching the following video to understand how i3 works.

Conclusion

Let me be clear: i3 is not for everyone. If you're a mouse person, if you don't like to spend time configuring your desktop, learning new tools, using the terminal, don't bother with i3. Linux desktop environments are amazing and have everything that a regular Linux user needs out of the box.

But, if you want to be more productive, learn better your Linux system, configure your system as you want or want to use more terminal applications and less the mouse, I would urge you to at least try i3. Set aside some time to learn the default key bindings, learn how to configure it and use it for a couple of weeks. Don't give up before that. Let your muscle memory work =).

See Also

Why I use Fedora
Creating a Ubuntu Desktop instance on Azure
Building and Running ASP.NET Core apps on Linux

Further Reading