[PATH wayland] allow clients to connect to a socket located on a different dir than XDG_RUNTIME_DIR

Bettio, Davide davide.bettio at ispirata.com
Thu Feb 5 08:42:15 PST 2015

commit 1ebae6d4f27ff0d336f2df0b8821099d2b2e510e
Author: Davide Bettio <davide.bettio at ispirata.com>
Date:   Thu Feb 5 17:04:42 2015 +0100

     Added support to optionally use WAYLAND_CLIENT_SERVER_SOCKET_DIR 
instead of XDG_DIR.

     WAYLAND_CLIENT_SERVER_SOCKET_DIR should not to be confused with 
     WAYLAND_CLIENT_SERVER_SOCKET_DIR is used by wayland client 
applications to connect
     to a server socket which is located on a different path.
     By using two different env vars it makes possible to specify a 
different directory
     for the nested server socked in case of nested compositors.

     Signed-off-by: Davide Bettio <davide.bettio at ispirata.com>

diff --git a/src/wayland-client.c b/src/wayland-client.c
index b0f77b9..81ba69b 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -700,9 +700,12 @@ connect_to_socket(const char *name)
  	const char *runtime_dir;
  	int name_size, fd;

-	runtime_dir = getenv("XDG_RUNTIME_DIR");
+	runtime_dir = getenv("WAYLAND_CLIENT_SERVER_SOCKET_DIR");
  	if (!runtime_dir) {
-		wl_log("error: XDG_RUNTIME_DIR not set in the environment.\n");
+		runtime_dir = getenv("XDG_RUNTIME_DIR");
+        }
+	if (!runtime_dir) {
+		wl_log("error: either XDG_RUNTIME_DIR or 
WAYLAND_CLIENT_SERVER_SOCKET_DIR are not set in the environment.\n");
  		/* to prevent programs reporting
  		 * "failed to create display: Success" */
  		errno = ENOENT;

More information about the wayland-devel mailing list