41

I have two outputs that I'd like to use on my laptop:

  • LVDS1 – 1366×768
  • HDMI1 – 1920×1080

I set my monitors up like so:

xrandr --output LVDS1 --auto --output HDMI1 --auto --right-of LVDS1

This is all well and good, but my laptop sits considerably lower than my external monitor, and with the top edges of the screens being aligned, it makes the jump from one screen to the other rather unintuitive. Is there a way I can align the bottom edges instead? I thought I could use the --pos flag to do this, but I have tried and not seen any difference (perhaps I do not know how to use it properly).

4 Answers 4

62
 xrandr --output LVDS1 --auto --pos 0x312 --output HDMI1 --auto --pos 1366x0

Basically, --pos specifies the position of the upper left corner of the screen in the virtual screen space. The virtual screen is a screen that spans your entire physical screens. This is a very generic way of specifying screen positions.

You want this configuration:

(virtual screen coordinates)
     0       1366                 1366+1920
   
   0           A-----------------------
               |                      |
               |                      |
               |                      |
  x? B---------|         HDMI         |
     |         |                      |
     |  LVDS   |       1920x1080      |
     |1366x768 |                      |
1080 ----------------------------------

And you need the coordinates of A and B to use in the --pos option. x is easily solved as 1080 - 768 = 312, so A is at (1366,0) and B is at (0,312).

Therefore, the appropriate --pos options are --pos 1366x0 for HDMI and --pos 0x312 for LVDS. You don't have to specify the virtual screen size (anymore), it is resized automatically.

Note that --pos can be abused, for exemple to create a hole between your two screens, or create overlapping. Most (all?) WM will not be able to handle that through.

EDIT: oh, you want the other way around, fixed that.

6
  • Heh, figured this out right before you posted. Would you be able to explain how the --pos flag works?
    – elynnaie
    Oct 8, 2012 at 20:11
  • Thanks, this makes a lot of sense! I think you want to replace 1600 with 1080 in your example, though.
    – elynnaie
    Oct 9, 2012 at 7:37
  • @denaje: Fixed.
    – BatchyX
    Oct 9, 2012 at 17:50
  • 3
    Is there no way to do it within xrandr without using magic values? I'd like to have a script that works regardless of the resolution of the screen I plug in. If not I guess I could extract the values from xrandr's output, but that sounds a little tedious…
    – Khaur
    Jul 24, 2014 at 11:57
  • 1
    At my case, using i3wm (not sure if relevant) and a 3-monitor layout, I had to use a negative y value for the highest monitor, instead of positive y values for the shorter ones. As an example this didn't work: --pos 0x240 --pos 1920x0 --pos4480x240, but this did work: --pos 0x0 --pos 1920x-240 --pos 4480x0 Jan 8, 2021 at 11:24
11

In addition to @BatchyX's excellent answer, an alternative —and IMO more convenient— option could be using ARandR (which stands for "Another XRandR GUI"):

ARandR is designed to provide a simple visual front end for XRandR. Relative monitor positions are shown graphically and can be changed in a drag-and-drop way.

You might need to install it first, but it's available in most distros' repositories. Here's how it looks for me on LXDE, for a setup with one external monitor connected via VGA, above, and the native (netbook-size) monitor underneath it:

ARandR screenshot

1
  • 2
    One nice thing about it is that it can save scripts with xrandr command, allowing you to quickly switch between layouts (e.g. turn off/on one monitor) by simply launching the script. The GUI itself is not very useful nowadays because most DEs provide similar GUI in settings.
    – AlexP11223
    Dec 19, 2020 at 18:13
4

If you looking for a drag-and-drop GUI-based solution, I can recommend ARandR.

It allows you to set the most important XRandR settings, e.g. screen position and resolution, which then can be saved in form of a shell script that calls xrandr with the corresponding parameters.

2

Someone managed ... hope this helps?

Dual Screens with aligned bottom edges

Dual-screen setup with aligned bottom edges

For the sake of anyone else who’s fighting their screens, I’ve got a script that will do this (but very very slowly)

setup script

xrandr --output VGA1  --auto
xrandr --output LVDS1 --auto
xrandr --output VGA1  --rotate left
eval "`monconf`"

monoconf script

#!/usr/bin/env python
import subprocess
output = >subprocess.check_output(["/home/tag/.bin/mon.ls"])
output = [ item.split() for item in >output.split("\n") ]

mons = {}

for mon in output:
   if len(mon) > 0:
       if mon[1] == "connected":
           res=mon[2]
           res=res.split("x")
           for item in res[1].split("+"):
               res.append(item)
           res.pop(1)
           mons[mon[0]] = res

BOTTOM_LEFT = "LVDS1"
TOP_RIGHT="VGA1"

LEFT_WIDTH  = mons[BOTTOM_LEFT][0]
LEFT_HEIGHT = mons[BOTTOM_LEFT][1]

RIGHT_WIDTH  = mons[TOP_RIGHT][0]
RIGHT_HEIGHT = mons[TOP_RIGHT][1]

print "xrandr --output %s --pos 0x%s" % (
   BOTTOM_LEFT,
   (int(RIGHT_HEIGHT) - int(LEFT_HEIGHT)))
print "xrandr --output %s --pos %sx0" % (
   TOP_RIGHT,
   int(LEFT_WIDTH)
)

and the mon.ls command

xrandr -q | grep "^[^\ ].*" | grep -v Screen

All of this is super hacky, but it works

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .