External monitor on Linux

1. On each connect

Short command to set the correct resolution and scaling for an external monitor.
I've decided to write this down because the --scale-from parameter seems to be uncommon. Most suggestions on the internet only use --scale, which I find less intuitive to use.

# XPS 13 with full hd display
xrandr --output DP1 --primary --mode 1920x1080 --scale-from 1920x1080 --same-as eDP1
# XPS 15 with 4k display on an external WQHD display
xrandr --output DP1 --primary --mode 2560x1440 --scale-from 3840x2160 --same-as eDP1

2. Automate it by using autorandr

sudo pacman -S autorandr
sudo systemctl enable --now autorandr.service

I've created two profiles.

autorandr should switch to the correct mode automatically (hence the name) from now on.

What's neat: If you close the lid while the notebook is connected to the external monitor, it doesn't go into sleep mode.