4

I understand that a screen is identified by :D.S where:

  • D is the display number
  • S is the screen number

I'm looking to list all screens associated with a display.

I can get all the current displays with something like cd /tmp/.X11-unix && for x in X*; do echo ":${x#X}"; done but I found no way of listing the screens for a specific display.

Also, I'm looking to get the display and screen number associated with a screen name. For example, with xrandr -q returning :

HDMI1 connected 1920x1080+0+328 (normal left inverted right x axis y axis) 290mm x 170mm
<snipped>

Is there a way to get the X identifier for HDMI1, something like :0.0 ?

Thanks for any lead you might provide!

M-Gregoire
  • 145
  • 1
  • 1
  • 5
  • Since XRandR treats all outputs as one screen you can use :D.S+X,Y with the X,Y offsets of the screen location (obtained via xrandr) – elig Jun 18 '21 at 11:31

2 Answers2

8

I'm looking to list all screens associated with a display.

xdpyinfo | grep -A4 '^screen'

Also, I'm looking to get the display and screen number associated with a screen name. For example, with xrandr -q returning :

They're not associated. All of the outputs shown by xrandr are parts of the same display and screen.

But if your x11 server ("display") is configured with more than one screen ("screen" being here the abstraction used by x11, not a physical monitor or such), you can select which one xrandr will show info about with xrandr --screen snum, or with --display :dnum.snum. If those options are not used, xrandr will only display info about the first screen configured, not about all of them.

Notice that x11 can (and will, by default) handle multiple monitors as parts of the same "screen", provided that they have the same depth.

4

The screens mentioned with :D.S are associated with an obsolete style of multi-screen X11 displays, in which each application was "trapped" on the screen it was started on, unless it had special facilities to switch from one screen to another.

Think about an early professional CAD workstation with CRT displays: it might have had one "main" display with a very limited number of colors but high refresh rate (to minimize eyestrain) for working with the design, and another display with a lower refresh rate but better color capabilities, dedicated to viewing the resulting design rendered in full color.

Today, the standard approach is to join all the physical screens into one large unified display surface, so that you can move windows freely between the screens. As a result, the screen number in the :D.S pair is practically always 0. To manage these kinds of setups, a new X11 protocol extension, X Rotate and Resize, or XRandR for short, was developed.

There is another extension called XINERAMA for reporting this multi-display layout to applications, so that they can, for example, display a dialog box in the middle of a physical screen and not half in one physical screen and half in another in a two-screen configuration.

When your DISPLAY environment variable is set to e.g. :0.0 and the XRandR extension is available, then xrandr will connect to that X11 display and can drill down into the physical display configuration underlying X11 "display 0, screen 0".

telcoM
  • 87,318
  • 3
  • 112
  • 232