Switching to i3

Two years ago I switched from macOS to Linux on my main machine. I went for a standard Ubuntu 16.04 setup without any bells or whistles. A few months in and Ubuntu announced it would swap Unity for GNOME, my second desktop environment to discover. I couldn't have told you the difference between both a few years ago, now they feel like old friends.

I have always known tiling window managers existed but only Linux neckbeards use them. Since I am no longer only a Vim user but also a Linux one, I probably qualify as one now. Vim took some time to get used to but I never looked back, so why not try a tiling window manager for a while?

A Tiling Window Manager

A tiling window manager shows windows on a screen. It differs from your usual Windows or macOS desktop since windows in a tiling window manager don't overlap. You don't "hide" one window behind another. Linux being Linux has a few options: Awesome, bspwm, dwm, i3, sway, and xmonad to name a few.

I went with i3 since it seems to be one of the simpler ones. There is also i3-gaps which, to my understanding, is more or less the same with an added margin around the windows. Let's stick with i3 for now as it's easier to install. A simple “sudo apt install i3” on Ubuntu 18.04 should do the trick.

Getting Started

Log out and when you log back in you'll see a little gear icon under the password field, click and choose i3 form the list.

You are greeted with a minimalistic screen: a status bar at the bottom and a question if it needs to create a config file, press enter. Next i3 asks for your modifier key, I went for alt, we'll call that $mod from now on.

hDPI Support

The standard UI is extremely small on my Dell XPS 13 hDPI screen. Press $mod+enter to open your first terminal an edit the ~/.Xresources file (create it if it doesn't exist yet).

Xft.antialias: true
Xft.hinting: true
Xft.rgba: rgba
Xft.hintstyle: hintfull
Xft.dpi: 220

Log out with $mod+shift+e and back in, this should be better: crispy hDPI text.

WiFi Not Working

I didn't have an ethernet cable close and the wireless connection didn't seem to work. I configured the wireless connection earlier and was surprised it didn't autoconnect. Welcome to i3, no hand-holding here, it only does what you tell it to do.

You need to run the network manager applet. Add this snippet to your ~/.config/i3/config and reload i3 with $mod+shift+r.

exec_always --no-startup-id nm-applet

You'll see a new icon in the bottom right corner of the screen connecting with your previously configured WiFi network.

Media Key Support

The volume and screen brightness keys didn't work out-of-the-box. The keyboard brightness one does so I guess those are hardware keys.

As before, you'll need a few tweaks to your ~/.config/i3/config file.

bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5%
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5%
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle
bindsym XF86MonBrightnessUp exec xbacklight -inc 10
bindsym XF86MonBrightnessDown exec xbacklight -dec 10

and reload i3 with $mod+shift+r. This fixed the volume up. down, and mute keys but not the screen brightness.

Looking more closely I realised it uses the xbacklight program which wasn't yet installed. A simple “sudo apt install xbacklight” will fix that.

A quick test by running xbacklight from the command line showed a new issue: “No outputs have backlight property”. This is potentially a missing /sys/class/backlight directory but I already had one. What I did not have, however, was the config file. create a /etc/X11/xorg.conf file and tell it what device to use.

Section "Device"
    Identifier  "Intel Graphics" 
    Driver      "intel"
    Option      "Backlight" "intel_backlight"

Tried once more and, sure enough, volume keys and screen brightness are now working.

Lock Screen

I work in a co-working office so locking my screen is an absolute must. i3 does not offer an out-of-the-box lock screen but you can install their i3lock package. I went for GNOME's screensaver. “sudo apt install gnome-screensaver” and add the following to your i3 config:

bindsym $mod+Shift+o exec gnome-screensaver-command --lock

First Hour

One hour in and I have a super simple working i3 setup! I switched to Linux two years ago since macOS was no longer exciting. Today I had exactly the same experience with i3: a ton of new stuff to learn, a little closer to understanding how computers work, and that fantastic feeling when you discover a whole new word!

This post is open source. Did you spot a mistake? Ideas for improvements? Contribute to this post via Github. Thank you!