Andy Crouch - Code, Technology & Obfuscation ...

Automatic i3 Multiple Monitor Configuration With Autorandr

Photo: Unsplash - Fotis Fotopoulos

Six months ago I wrote about scaling up my desk set up and moving to three screens. In doing so I hit something that was a minor problem, screen management.

I use the i3 window manager and on the whole, it is pretty good about handling screens once you have set the configuration. To do that I have been using ARandR which is a UI for XRandR which in itself is a tool for setting the screen configuration. The nice thing with ARandR is you can save configs as separate config files. You can just open and apply the configs as needed when you move between screen setups. The only drawback was having to set a config upon starting my laptop.

My first thought was to set a keybinding for each config I have which would be an improvement. I started to search out how to do that and instead found a much better solution, autorandr.

autorandr is a small app that will auto detect and update your config settings based on connected devices. It actually works really well and after playing with it over a weekend I have settled on this as my preferred way of handling screen configuration going forward.

To install autorandr you can grab the official package from your repo or install it following the instructions here. Once installed you can create different configurations as follows:

$ autorandr --save laptop

“laptop” here is the name of the configuration of the current monitor setup. To create each config just plug in your various screen combinations and save each one.

Now autorandr can detect which hardware setup is active:

$ autorandr
laptop (detected)

To automatically reload your setup:

$ autorandr --change

To manually load a profile:

$ autorandr --load <profile>

or simply:

$ autorandr <profile>

It really is that simple. The great thing is that once you have your configurations set up then autorandr does the rest. Each time I change the connected screens it just loads the correct config and the screens are adjusted automatically. Such a great utility.

If you have any questions or further tips for using autorandr then let me know via twitter or email.