I recently switched my external display setup from two 1600x1200 monitors to a single 4K monitor. It’s a bit more difficult for my aging eyes, but the increase in total resolution hs been great. I also love that “all” of my monitors are now on a monitor arm, freeing more desk surface up, and making it easier to convert my desk from sit to stand mode (previously, only one of my two monitors had been mounted on an adjustable arm). It’s really been a great improvement!

Somewhat unexpectedly, though, I’ve found that it makes it harder for me to undock my laptop and cart it around. On the 4K display, it’s ludicrous to run things maximized, so I typically have at least four (often more!) windows all going at once, arranged in different portions of the screen. When I undock, though, that layout falls apart. Even worse, Gnome 3 collapses all of my workspaces down to just one, leaving me to re-sort the dozens of windows back into their proper place. These are minor problems, all things considered, but they’ve made me very reluctant to dock/undock my laptop. Given that we just wrapped up a longer-than-usual winter, that really grates – I want to be outside on the porch enjoying the gorgeous weather!

So what to do? Well, for a while now I’ve been considering switching to a tiling window manager. I had similar problems, though to a lesser degree, even with my previous setup and I’ve always suspected that a tiling layout would solve the problems. So: I started doing some research this weekend. Here’s a giant brain dump of what I’ve learned:

  • Arch’s wiki provides a useful list of tiling display managers: https://wiki.archlinux.org/index.php/Comparison_of_tiling_window_managers.
  • Of those, i3 seems to be the most popular.
    • That may change in the future if/when Wayland gains popularity, as i3 doesn’t support it (and seems unlikely to).
    • But I’m not using Wayland, and can’t, due to NVIDIA suckage, so that’s not relevant right now.
  • Installing the i3 package and restarting on Ubuntu 18.04 was enough to get things running.
    • Did have to restart the system before the option to log into an i3 session appeared.
  • i3’s User Guide is pretty solid: https://i3wm.org/docs/userguide.html#_interprocess_communication.
  • I’m not smart enough to use nmcli for network/wifi management, it seems, so I needed to enable i3bar’s tray output, per https://wiki.archlinux.org/index.php/I3#Tray_icons_not_visible.
    • This won’t work unless/until you mark the display as --primary in xrandr.
  • It turns out that Gnome was managing my external displays for me behind the scenes; that wasn’t the NVIDIA settings or X settings or anything like that. i3, however, doesn’t do that for you. Instead, turning on/off external monitors and all of that fun stuff has to be done by hand, typically with xrandr.
  • Power management is also different with i3 than it was with Gnome. Specifically, I noticed that my laptop started going to sleep when I closed the lid (e.g. after docking it).
  • Each i3 workspace is explicitly associated with a display. If you switch displays, you have to move the workspaces to the new one(s).

Problem Solving: Stay Awake

References:

It’s not super useful to have the laptop go to sleep every time I dock it and close the lid. I resolved this, as follows:

  1. Add the following lines to /etc/systemd/logind.conf:
      HandleLidSwitch=ignore
      HandleLidSwitchDocked=ignore
    
    • Note that this fixed the problem for me, even though it looked like the default settings here shouldn’t cause a suspend.
  2. Restart the system, or at least the systemd-logind service. (Either one of these will kill your i3 session, FYI.)

Problem Solving: Manually Switching Displays

As mentioned above, i3 doesn’t have any fancy control panels like Gnome for managing displays. Instead, displays need to be managed directly via the xrandr command line tool. Here are some sample commands I use to switch around my displays:

  • To turn on both LVDS-0, the laptop display and DP-3, the external 4K display at the same time:
    $ xrandr --output LVDS-0 --auto --primary --output DP-3 --auto --rate 30.0 --right-of LVDS-0
    
  • To switch to just DP-3, the external 4K display:
    $ xrandr --output LVDS-0 --off --output DP-3 --auto --rate 30.0 --primary
    
  • To switch to just LVDS-0, the laptop display:
    $ xrandr --output LVDS-0 --auto --primary --output DP-3 --off
    

Note: I initially ran into some trouble with this, until I realized that my laptop can’t drive DP-3 at the default 60.0 Hz. I learned this by logging back into Gnome, getting the displays configured the way I wanted them, and running xrandr with no options to see how things were actually configured.

Second Note: After connecting my external display, the xrandr commands to turn it on often fail. Still not sure why yet, but disconnecting and reconnecting it and trying again seems to fix it after a few tries.

Problem Solving: Audio Controls

i3 doesn’t come with any builtin way to manage volume, mute/unmute, etc. My Ubuntu system uses PulseAudio, so I can get by, though painfully, by using the command line utilities for it, as described here: http://terokarvinen.com/2015/volume-control-with-pulseaudio-command-line-tools.

If I wanted to, I could probably wire up those commands to some keyboard shortcuts and leave it at that, but I’d prefer to have a GUI, personally. My first try at this is using pasystray, which is prett terribly, but has the advantage of being available in Ubuntu’s default repositories:

$ sudo apt install pasystray
$ pasystray &> /dev/null &

This will add a little volume icon in the systray that you can hover over and then use the mouse wheel to change the volume. For some reason, every other option it has seems disabled. Whatever: good enough for now.

Problem Solving: Cheatsheet

I made a number of customizations to the default key bindings. Most notably, I switched out the default j k l ; bindings for Vim-muscle-memory-friendly h j k l. This and the other customizations I made are all great, but invalidate the visual layout cheatsheets that are provided towards the top of the i3 User Guide.

Happily, I came across a great online shortcut cheatsheet generator: Keyboard Layout Editor. Here are the layouts that I generated for my config:

mod Bindings:

i3 mod Bindings

mod+Shift Bindings:

i3 mod+Shift Bindings