Use xrandr

2019-11-04

Linux has some good and some bad tools. Examples of good tools are xrandr and ffmpeg. You can use xrandr to configure screens in a very generic yet powerful manor.

I recently bought a new screen and linux has some trouble reconnecting to it properly. To fix this I have a little script to fix my screens.

Code:
paplay /usr/share/sounds/freedesktop/stereo/complete.oga
xrandr --output HDMI-2 -s 2560x1440 --rate 60
xrandr --output DP-1 -s 2560x1440 --rate 100
xrandr --output eDP-1 --off
xrandr --output HDMI-2 --left-of DP-1
paplay /usr/share/sounds/freedesktop/stereo/complete.oga

I bind this to a shortcut (usually super+Fx) through the keyboard configuration. Since I won't see the output I add a paplay command to indicate start and end of the script.

The first command sets the HDMI output to 2560x1440 at 60hz. The second command does the same for the DisplayPort. The third turns off the laptop screen, since I won't use it. And the fourth puts the HDMI left of the DisplayPort.