I am running the script on a desktop with a monitor connected using HDMI. When the display starts up, it defaults to the laptop LCD monitor. There should be a way to customize which display the script loads on.
Which X server option do you use?
If it is a nested X server like with option --xephyr, x11docker cannot do much about it.
If it is --xorg or --weston-xwayland from tty, please show me the output of xrandr.
It should work to configure the displays like you would in a regular desktop environment. That can be done with tools in container as well as with tools from host. (Tools from host would need DISPLAY and XAUTHORITY.)
If you can figure out an xrandr command that fits your needs, you can run x11docker with something like
--runfromhost "xrandr --output VGA1 --primary --right-of eDP"
Thanks for your reply; the output for my xrandr is below from the GUI shell on Ubuntu. If I try this on a console session though, I get an error that Can't open display. But if I try launching x11docker on the console session, it works. I am not sure if the output of xrandr would be different on a console session.
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
eDP-1 connected (normal left inverted right x axis y axis)
2560x1600 59.97 +
2560x1440 59.99 59.99 59.96 59.95
2048x1536 60.00
1920x1440 60.00
1856x1392 60.01
1792x1344 60.01
2048x1152 59.99 59.98 59.90 59.91
1920x1200 59.88 59.95
1920x1080 60.01 59.97 59.96 59.93
1600x1200 60.00
1680x1050 59.95 59.88
1600x1024 60.17
1400x1050 59.98
1600x900 59.99 59.94 59.95 59.82
1280x1024 60.02
1440x900 59.89
1400x900 59.96 59.88
1280x960 60.00
1440x810 60.00 59.97
1368x768 59.88 59.85
1360x768 59.80 59.96
1280x800 59.99 59.97 59.81 59.91
1152x864 60.00
1280x720 60.00 59.99 59.86 59.74
1024x768 60.04 60.00
960x720 60.00
928x696 60.05
896x672 60.01
1024x576 59.95 59.96 59.90 59.82
960x600 59.93 60.00
960x540 59.96 59.99 59.63 59.82
800x600 60.00 60.32 56.25
840x525 60.01 59.88
864x486 59.92 59.57
800x512 60.17
700x525 59.98
800x450 59.95 59.82
640x512 60.02
720x450 59.89
700x450 59.96 59.88
640x480 60.00 59.94
720x405 59.51 58.99
684x384 59.88 59.85
680x384 59.80 59.96
640x400 59.88 59.98
576x432 60.06
640x360 59.86 59.83 59.84 59.32
512x384 60.00
512x288 60.00 59.92
480x270 59.63 59.82
400x300 60.32 56.34
432x243 59.92 59.57
320x240 60.05
360x202 59.51 59.13
320x180 59.84 59.32
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
HDMI-2 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 820mm x 460mm
1920x1080 60.00*+ 59.94 24.00 23.98
1920x1080i 60.00 59.94
1600x1200 60.00
1400x1050 59.95
1280x1024 60.02
1360x768 60.02
1280x720 60.00 59.94
1024x768 75.03 70.07 60.00
1440x480i 59.94
800x600 72.19 75.00 60.32 56.25
720x480 60.00 59.94
720x480i 60.00 59.94
640x480 75.00 72.81 60.00 59.94
720x400 70.08
Likely eDP-1 is your laptop monitor, and HDMI-2 is your second monitor.
For your setup it likely works to add this option to x11docker:
--runfromhost "xrandr --output HDMI-2 --primary --right-of eDP-1"
or, if your second monitor is on the left side of the laptop:
--runfromhost "xrandr --output HDMI-2 --primary --left-of eDP-1"
If you need this often and don't want to type that much, you can use option --preset: https://github.com/mviereck/x11docker#option---preset
I will try this at least on the GUI session. Any idea if the xrandr output would be valid for my local console session too since the xrandr command doesn鈥檛 execute successfully there. But x11docker starts up fine on my local console session (the one using Ctrl Alt F3 for example)?
The option should work as well on console.
xrandr only works in a running X server, so it fails on console. It would work in an x11docker session within a container. The output should be the same as on your host desktop.
If you're running xrandr from the same shell you ran x11docker from then you are missing the DISPLAY & XAUTHORITY env variables, so xrandr is trying to open display & it also doesn't have the cookie to authenticate to the Xserver with.
You'll need to do something like this (assuming you wanted to query display 0):
XAUTHORITY=/path/to/.Xauthority xrandr -D :0 -q
you can print to stdout the generated x11docker environment by specifying --showenv in your x11docker command.
mviereck's suggestion to use the --runfromhost option is easier as the environment is already setup by x11docker.
@rohitsud Did this work for you? Can the ticket be closed?
It almost works; X11docker loads the application on the correct monitor (HDMI). But the resolution it uses is my laptop LCD resolution (2560x1600). Is there a way for it to let it auto-detect the resolution supported by my HDMI monitor?
But the resolution it uses is my laptop LCD resolution (2560x1600).
Your xrandr output shows that your HDMI monitor supports at most 1920x1080. How can it show 2560x1600?
Nonetheless, you can add the desired resolution to the xrandr command, e.g.
--runfromhost "xrandr --output HDMI-2 --primary --right-of eDP-1 --mode 1920x1080"
I guess I didn't word the problem properly, sorry about that.
Here's a link to photos that show what I am seeing.
The blue photo is of the KODI app that I am trying to launch on my HDMI TV. Note that only the top left of the screen appears.
The other pictures are of my laptop LCD and mirrored HDMI display logged in using a Linux console. Note that the HDMI monitor is trying to use the higher resolution of the laptop LCD and is therefore cropping the bottom few lines in the console that are visible in the laptop LCD but not in the HDMI.
I am wondering if while launching x11docker, I can override the resolution that is used; the text is tiny in the pictures but I already tried using 1920x1080 as the mode in the xrandr command and it doesn't seem to do anything.
So you get a mirrored output, both monitors show the same content? This should not happen with the --right-of option.
To at least avoid the cropped output, set the laptop monitor to the same size as the HDMI output:
--runfromhost "xrandr --output HDMI-2 --primary --right-of eDP-1 --mode 1920x1080 --output eDP-1 1920x1080"
Basically the issue is all about to. find a good xrandr setup. It might be easier to run a terminal in container.
For example, run x11docker --xorg x11docker/check xfce4-terminal and try out some xrandr setups in the container terminal until you find one that works for you.
Overall, xrandr --auto should already give a basically good setup.
Edit: It is also possible that kodi does not recognize the correct resolution. You could check if kodi provides some display options, too.