Running multiple xserver displays “offscreen” or “headless”

x11

I would like to run two or more displays, while I only have one GPU and one monitor. The second display does not have to display anything on the monitor, a dummy output would be ideal.

I use startx to start a new display:

startx -- :1

so far so good, I can switch between the two displays on my computer using Ctrl+Alt+Fx (where x is a number, on my computer it is 7 or 8).

Here's the problem, when both displays are available and I am currently on display 0 and I try to record display 1 I get a black screen in the recorded video. The main issue seems to be that the xserver is not refreshing when the tty is not active.

I have confirmed that recording via. ffmpg's x11grab or using VLC works as intended.

Other than this I have tried Xephyr, Xnest and Xvfb, while they do that I need, I am unable to use them because what I am running in display 1 is graphically very demanding (OpenGL) and I am also recording on top of that.

I also tried using the xserver-xorg-video-dummy together with the Xdummy script to start the display, it works, but not with OpenGL applications.

Any help with this issue is greatly appreciated!

Best Answer

I found a decent workaround using Xephyr and VirtualGL!

Install both Xephyr and VirtualGL, then fire up Xephyr with your preferred settings:

Xephyr -screen 1024x768 :1

If everything went well, you will now be able to launch executables with OpenGL acceleration in Xephyr!

DISPLAY=:1 vglrun -- glxgears
Related Question