Positioning Multiple Monitors From the Command Line

On rare occasions, I end up needing to plug a second monitor into my laptop. This is a problem I solved in the past with a GUI, but it turns out there’s also a pretty easy-to-use command-line tool for this purpose: xrandr.

To use, first run it by itself


This will list your current monitor configuration, which will look something like this:

Screen 0: minimum 320 x 200, current 5569 x 2520, maximum 16384 x 16384
eDP-1 connected primary 1920x1080+0+1440 (normal left inverted right x axis y axis) 309mm x 174mm
   2560x1440     60.00 +  60.00
   1920x1440     60.00
   1856x1392     60.00
   1792x1344     60.00
   2048x1152     60.00
   1920x1200     60.00
   1920x1080     60.00*
   1600x1200     60.00
. . . etc . . .
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-2 connected 3440x1440+2129+0 (normal left inverted right x axis y axis) 800mm x 335mm
   3440x1440     59.97*+  29.99
   2560x1440     59.95
   2560x1080     60.00    60.00    59.94
. . . etc . . .

The starred rows are the configurations currently selected for the monitor.

To position the monitors (in this example),

xrandr –output eDP-1 –pos 0x0 –output DP-2 –poz 0x-1440

That puts the secondary monitor above the primary monitor (by offsetting its y-coordinate---measured from top-left---to negative height-of-the-screen).