Automatically change multi-monitor setup

Intro

When using only window manager (WM) you need to care about the configuration of multiple monitors.

Goal:

  • when I connect the external monitor - I want my external monitor to be primary

  • when I disconnect the external monitor - I want laptop monitor to be primary

Manual setup

Install and use arandr to configure your multi-monitor setup

Add automation

Install autorandr.

Connect your external monitor.
Configure your setup with xrandr.
Execute autorandr --save dual to save your multi-monitor configuration.

Disconnect external monitor.
Configure your setup with xrandr.
Execute autorandr --save laptop to save your "laptop only" configuration.

The cool thing about autorandr that it automatically detect your hardware and change to profile you have.

To make it automatic during your login add autorandr --change to autostart.
In my case this is ~/.config/qtile/autostart.sh file.

Done ๐ŸŽ‰

ย