If you run separate displays on each monitor (less likely these days), the DISPLAY environment variable is what you want.
If you are using Xinerama (distributing one logical output to multiple monitors), however:
- In addition: X11 dictionary: "Display" is one or more "screens" with input devices; for example a keyboard and mouse, aka "place". A “screen” is a logical canvas that is partially or fully displayed on one or more “monitors”; when using multiple monitors for one “screen”, the windows can be partially displayed on each monitor, but they have the same X11
DISPLAY identifier; This is called Xinerama. The DISPLAY format is the host number : display-number . screen-id, for example. on my Xinerama setup, both monitors are part of screen 0 on the displayed number, which counts from 0 with every registered user on the same host. "Seats" are logical monitoring + input groups that use different hardware; multiple "mappings" may occur using the "virtual console" switching, as Gnome and KDE allow multiple users to register on the same "seat".
Most GUI tools allow you to specify window geometry using the --geometry or -geometry .
Qt uses the old MIT style -geometry form. GTK + / Gnome uses the GNU --geometry style.
This assumes that you allow Qt to post-process your command line, for example. passing argv to QtApplication or similar.
The "logical display" will have a resolution that is the sum of the resolutions in each direction of the location of your monitors. For example, I have 2 × 1920 × 1080 displays connected right now. xrandr reports:
Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 8192 x 8192
To display the window on the right monitor, I can specify a geometry line that has x coordinates between 1920 ... 3839 (inclusive).
The usual format is width x height ± x-offset ± y-offset - but width and height are optional if you prefer to accept the default values. ± are + for counting relative to the top / left or - for counting relative to the bottom / right.
So for example:
gedit --geometry 800x600+1920+0
Unfortunately, the only software way I know to determine the display area on each monitor from the shell would be to analyze the output from xrandr ; eg.
$ xrandr Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 8192 x 8192 LVDS1 connected (normal left inverted right x axis y axis) 1366x768 60.0 + 1024x768 60.0 800x600 60.3 56.2 640x480 59.9 VGA1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 510mm x 287mm 1920x1080 60.0*+ 1680x1050 60.0 1280x1024 60.0 1440x900 59.9 1280x720 60.0 1024x768 60.0 800x600 60.3 640x480 60.0 720x400 70.1 HDMI1 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 510mm x 287mm 1920x1080 60.0*+ 1680x1050 59.9 1280x1024 60.0 1440x900 59.9 1280x720 60.0 1024x768 60.0 800x600 60.3 640x480 60.0 720x400 70.1 DP1 disconnected (normal left inverted right x axis y axis) $ xrandr | perl -ne 'if (/(\d+)x(\d+)\+(\d+)\+(\d+)/) '\ > ' { print "$3,$4 - ", $3 + $1 - 1, ",", $4 + $2 - 1, "\n" }' 0,0 - 1919,1079 1920,0 - 3839,1079
(Normally, you need to avoid splitting the single-line layer into two lines in the shell, but the '\ ... ' trick should make it legible on SO.)