It all depends on what your DISPLAY
environment variable is set to. That indicates the socket that represents the connection to the display server; for :0.0
, that's a Unix-domain socket (typically /tmp/.X11-unix/X0
, but not necessarily; it's up to an agreement between your Xserver and your Xlib). If you've not got permission to access that socket in that directory, you won't be able to use that display.
There might also be some issues relating to the file named in the XAUTHORITY
environment variable, depending on exactly how the connection is secured and authenticated. There's a lot of possible complexity here, but the summary is that if a security key required to authenticate to the X server is stored in a file that the X client library can't read (or can't find), the connection will fail. This is independent of whether the socket is reachable in the first place (my preceding paragraph).