Using i3 with multiple monitors

Are you using multiple monitors with your Linux workstation? Seeing many things at once might be beneficial. But there are often much more windows in our workflows than physical monitors — and that’s a good thing, because seeing too many things at once might be distracting. So being able to switch what we see on individual monitors seems crucial.

Let’s talk about i3 — a popular tiling window manager that works great with multiple monitors. And there is one handy feature that many other window managers don’t have — the ability to switch workspaces on individual monitors independently.

Quick introduction to i3

The Fedora Magazine has already covered i3 about three years ago. And it was one of the most popular articles ever published! Even though that’s not always the case, i3 is pretty stable and that article is still very accurate today. So — not to repeat ourselves too much — this article only covers the very minimum to get i3 up and running, and you’re welcome to go ahead and read it if you’re new to i3 and want to learn more about the basics.

To install i3 on your system, run the following command:

$ sudo dnf install i3

When that’s done, log out, and on the log in screen choose i3 as your window manager and log back in again.

When you run i3 for the first time, you’ll be asked if you wish to proceed with automatic configuration — answer yes here. After that, you’ll be asked to choose a “mod key”. If you’re not sure here, just accept the default which sets you Windows/Super key as the mod key. You’ll use this key for mostly all the shortcuts within the window manager.

At this point, you should see a little bar at the bottom and an empty screen. Let’s have a look at some of the basic shortcuts.

Open a terminal using:

$mod + enter

Switch to a second workspace using:

$mod + 2

Open firefox in two steps, first by:

$mod + d

… and then by typing “firefox” and pressing enter.

Move it to the first workspace by:

$mod + shift + 1

… and switch to the first workspace by:

$mod + 1

At this point, you’ll see a terminal and a firefox window side by side. To close a window, press:

$mod + shift + q

There are more shortcuts, but these should give you the minimum to get started with i3.

Ah! And to exit i3 (to log out) press:

$mod + shift + e

… and then confirm using your mouse at the top-right corner.

Getting multiple screens to work

Now that we have i3 up and running, let’s put all those screens to work!

To do that, we’ll need to use the command line as i3 is very lightweight and doesn’t have gui to manage additional screens. But don’t worry if that sounds difficult — it’s actually quite straightforward!

The command we’ll use is called xrandr. If you don’t have xrandr on your system, install it by running:

$ sudo dnf install xrandr

When that’s installed, let’s just go ahead and run it:

$ xrandr

The output lists all the available outputs, and also indicated which have a screen attached to them (a monitor connected with a cable) by showing supported resolutions. Good news is that we don’t need to really care about the specific resolutions to make the them work.

This specific example shows a primary screen of a laptop (named eDP1), and a second monitor connected to the HDMI-2 output, physically positioned right of the laptop. To turn it on, run the following command:

$ xrandr --output HDMI-2 --auto --right-of eDP1

And that’s it! Your screen is now active.

Second screen active. The commands shown on this screenshot are slightly different than in the article, as they set a smaller resolution to make the screenshots more readable.

Managing workspaces on multiple screens

Switching workspaces and creating new ones on multiple screens is very similar to having just one screen. New workspaces get created on the screen that’s currently active — the one that has your mouse cursor on it.

So, to switch to a specific workspace (or to create a new one in case it doesn’t exist), press:

$mod + NUMBER

And you can switch workspaces on individual monitors independently!

Workspace 2 on the left screen, workspace 4 on the right screen.
Left screen switched to workspace 3, right screen still showing workspace 4.
Right screen switched to workspace 4, left screen still showing workspace 3.

Moving workspaces between monitors

The same way we can move windows to different workspaces by the following command:

$mod + shift + NUMBER

… we can move workspaces to different screens as well. However, there is no default shortcut for this action — so we have to create it first.

To create a custom shortcut, you’ll need to open the configuration file in a text editor of your choice (this article uses vim):

$ vim ~/.config/i3/config

And add the following lines to the very bottom of the configuration file:

# Moving workspaces between screens 
bindsym $mod+p move workspace to output right

Save, close, and to reload and apply the configuration, press:

$mod + shift + r

Now you’ll be able to move your active workspace to the second monitor by:

$mod + p
Workspace 2 with Firefox on the left screen
Workspace 2 with Firefox moved to the second screen

And that’s it! Enjoy your new multi-monitor experience, and to learn more about i3, you’re welcome to read the previous article about i3 on the Fedora Magazine, or consult the official i3 documentation.

Fedora Project community

19 Comments

  1. Kaspers

    Nice guide your wrote here. Hopefully it’ll inspire people to make use of these tiling window managers. Have some experience with i3 myself, absolutely liked it. Moved a bit later to dwm.

  2. Ph0zzy

    Do you know how is goint to work with sway?

    • oyviaase

      Sway manages the monitors itself so you need to specify your monitor layout in your Sway configuration file. An example from the github wiki is this
      output HDMI1 pos 0 0 res 1920×1080
      output eDP1 pos 1920 0 res 1600×900

      https://github.com/swaywm/sway/wiki#multihead

    • plaguedoctor

      Sway has multiscreen support built in. How to set it up and use it is nicely explained in sway manpages. 🙂

  3. Curried

    Great guide!

    Any advice on dealing with multiple monitors and HiDPI? Resolution mismatch is ugly.

    I use mons (https://github.com/Ventto/mons) to manage my monitors on my i3/arch laptop. A bit easier than pure xrandr as it’s arguments are very common arrangements. But the most I do is mirror my laptop on external monitors to work around the hidpi issue.

  4. John

    sudo dnf install arandr

    then run arandr
    save the profile {it will generate a bash script which calls xrandr}
    That’s you GUI solution 🙂

    • Stephen

      Was going to chime in with this a same thing.

      arandr ++

      😀

  5. Hiisi

    The original article 3 years ago made me switch to i3wm. I have discovered how to use multiple screen just a few days ago. I wish this article were published a week earlier 🙂

  6. I made a mode like the resize mode. It can move workspaces to different outputs.

  7. Yazan Al Monshed

    Great article !, Thank you

  8. LegacyHater

    Just use sway ????

  9. Ryan Murphy

    multiple graphics cards with multiple monitors? I haven’t been able to get xinerama to work and the second gpu is the only one with dvi

  10. Thomas

    Does anyone have some hints on where to start when the above doesn’t work?

    I love i3, but using it on multiple monitors has not been a good transition.

    Everytime that I login to i3 I am greeted with nothing. No spinning cursor, my background colour is not loaded. I’ve used Arandr to setup a script to turn on the monitors and setup a keymapping to run it. On the first run it only enables one external monitor. The laptop and second monitor remain on the grey login screen background and don’t have the i3 toolbar along the bottom.

    Usually the second time I run the script it enables all three windows, but not always…

    I’m usually able to use the Arandr script I’ve setup to move all workspaces to just the laptop monitor when I need to undock, but the script to re-enable the external monitors fails more often than it works.

    So far i3 helps me work efficiently enough that it’s still better to reboot my laptop during re-docking events. However, it’s a significant pain point. Would greatly appreciate any nudges along the path to debugging.

    Unfortunately, I’m not sure where to even look for logs around this and google mostly returns articles at about this depth.

    • Eduard Lucena

      It’s weird, the initial setup is not tied to i3 directly, at least not in Fedora, since any versiona you have installed comes either with SDDM, GDM or LightDM and they are the responsible to setup your login screen (and the monitors). Now, after that, when you log in into i3wm, then you have the setup that was made by the DM, and if you need to change it, you should go with the ways explained in the article. At least, it works that way for me.

  11. Raphael Groner

    Does it also work with Displaylink adapters?

  12. tarek

    nice guide and thank you for this article

  13. Leslie Satenstein

    Adam,
    It is a very good informative article.
    I am just beginning with I3, and ran into an issue.
    My terminals open with white background and pale colors for text.
    Do you know how to change the terminal background color? I am OK with navigating and creating keymappings.

    • Depends on the terminal you’re using, it’s generally in the terminal settings themselves nothing really to do with i3

    • Hiisi

      Since I have gnome installed on my system I simply changed default terminal to gnome-terminal in i3′ config:

      start a terminal

      bindsym $mod+Return exec gnome-terminal
      It has black background by default 🙂

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions