4

I have an OpenGL program that will not run correctly inside a VNC session. In order to start it remotely in a VNC session, I need to run it via vglrun.

I already have a wrapper script that launches the binary, but I need a reliable way to detect if I should run it via vglrun or to run the app as is.

I'm currently using thinlinc, which appears to modify LD_LIBRARY_PATH, PATH, and several other environment variables. So worst case I could check to see if thinlinc is present there, but I was hoping there might be a more generic way to detect if you're running inside of a VNC session.

Matt
  • 1,415
  • 2
  • 15
  • 23
  • I'm not aware of any vnc server independent ways of detecting this, especially since implementations like `x11vnc` can use an existing, accelerated session where you would not use `vglrun` even though you're connected via vnc. Maybe you can recognize vglrun situations from `glxinfo` output? – that other guy Mar 31 '15 at 15:57

1 Answers1

3

You can use the standard Unix command xdpyinfo to get information about your display.

In fact, under VNC (at least under Real VNC), it reports the string VNC-EXTENSION among the list of available extensions, e.g.:

$ xdpyinfo

name of display:    CTNLL021:13.0
version number:    11.0
vendor string:    The X.Org Foundation
vendor release number:    60900000
X.Org version: 6.9.0
. . .
number of extensions:    29
    . . .
    GLX
    VNC-EXTENSION
    X-Resource
    . . .

Therefore you can test easily if you are under VNC with the following command:

xdpyinfo | grep VNC

and then checking its exit code.

If you need, you can also specify the display you're interested in, e.g.:

xdpyinfo -display myhost:22:0 | grep VNC
davidedb
  • 867
  • 5
  • 12