How to use Xrandr and I3 with multiple monitors

Bash
Tutorial
Author

Gninahophin Jean-Pierre Axel

Okay, first of all, this is kind of covered in the documentation.

And you should definitely read it. As always RTFM :)

I’m writing this for two kinds of people:

First you need to get the monitor working

The ‘just work’ solution until it doesn’t


xrandr --auto 

If it doesn’t work, try it a second time… and if it still doesn’t work, perhaps you should read the manuals but here’s a quick summary:

  • Just typing xrandr will give you a bunch of info on the detected displays, their names, and the resolutions. If your using a laptop, your laptop is probably something like edp-1.

  • In the list of screen resolutions, you might see a “+” indicating the default resolution - And you might also see “*”, which is the current resolution

  • To target a monitor you can use the “–output” flag followed by whatever options you want… there is an example below. If you have multiple monitors keep in mind you chain the instructions… once again, there’s an example below.

  • If you’re using a mouse… for some reason despite using a tiling window manager, using the –left-of/right-of flag followed by the monitor you want to will give you the incredible power of switching screens by going to your preferred side. Incredible, isn’t it? Other options are –below/above if you have a weird monitor setup and –same-as which essentially mirrors your screen to the “same-as” monitor. This is probably the option you want if you’re going to do some kind of public presentations.


xrandr --output eDP --primary --output HDMI-A-1-0 --left-of eDP
  1. Reload i3

So you just got your monitor working, congrats. It’s not working as expected ? Just reload i3!

Mod + shift + r should do the trick

  1. Troubleshooting

Okey, obviously it worked for me, and I have no idea what nasty bug you may have encountered. But here’s a few suggestions that might come in handy.

If you’re using Polybar, there’s actually a well-know simple script to make it work on all your monitors nicely leveraging Xrandr. Check it out.

If you’re using Wayland, just … why ?