Is it possible to save and load a display configuration?

I have 2 displays for my computer, and a lot of times I need to change the configuration (from extended desktop to single desktop, changing wich one is the main screen, etc etc)

I wonder if there is a way to save and load these configurations for quick access in the future. I am aware of the existence of xrandr and I know it will probably be possible to write an alias for each setting, just wondering if there is an easier way or am I going to read the manual for it and do it that way.


Install arandr

sudo apt install arandr

It is a graphical application where you can set all your screens in the way you want, apply the settings and afterwards you can save the settings (File -> Save As).

The best thing is that the settings are in fact saved as shell scripts with the needed xrandr command that applies your configuration. Since they are plain text files you can open them in the favorite text editor to learn the syntax for xrandr or to modify them to your liking. In the end you can assign keyboard shortcuts to these shell scripts (either via arandr or via the general keyboard configuration tool), or you can add them to the menus for easy access.

For example, I have a script initially made with arandr that extends the screen to the right and later modified it manually to also change Broadcast-RGB to Full for some of the monitors I use where the Auto setting does not work properly.

The arandr script looks like this, so as you see it is a single xrandr command, so once you learn how to do it arandr will no longer be needed.

#!/bin/sh
xrandr --output DP-1 --off --output HDMI-1 --set "Broadcast RGB" "Full" --mode 1920x1080 --pos 1920x0 --rotate normal --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-2 --off --output HDMI-1