[PATCH 3/3] Introduce WAYLAND_SERVER_SOCKET_DIR to change socket directory without changing XDG_RUNTIME_DIR. This might be useful to change socket directory in case wl_display_add_socket_auto is used. For example this will change the socket path for weston without using any command line argument. This envvar is ignored when WAYLAND_SERVER_SOCKET is set to an absolute path.

Davide Bettio davide.bettio at ispirata.com
Tue Mar 3 04:49:55 PST 2015


Signed-off-by: Davide Bettio <davide.bettio at ispirata.com>
---
 src/wayland-server.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/wayland-server.c b/src/wayland-server.c
index 05e9c07..2922e41 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -1093,9 +1093,12 @@ wl_socket_init_for_display_name(struct wl_socket *s, const char *name)
 	int name_size;
 	const char *runtime_dir;
 
-	runtime_dir = getenv("XDG_RUNTIME_DIR");
+	runtime_dir = getenv("WAYLAND_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: XDG_RUNTIME_DIR or WAYLAND_SERVER_SOCKET_DIR not set in the environment\n");
 
 		/* to prevent programs reporting
 		 * "failed to add socket: Success" */
@@ -1220,14 +1223,14 @@ wl_display_add_socket_auto(struct wl_display *display)
  * and WAYLAND_DISPLAY env variable for the socket name. If WAYLAND_DISPLAY and
  * WAYLAND_SERVER_SOCKET are not set, then default wayland-0 is used.
  *
- * The Unix socket will be created in the directory pointed to by environment
- * variable XDG_RUNTIME_DIR. If XDG_RUNTIME_DIR is not set, then this function
- * fails and returns -1.
+ * The Unix socket will be created in the directory pointed to by either environment
+ * variable WAYLAND_SERVER_SOCKET_DIR or XDG_RUNTIME_DIR. If the none of the is set,
+ * then this function  fails and returns -1.
  *
- * The length of socket path, i.e., the path set in XDG_RUNTIME_DIR and the
+ * The length of socket path, e.g., the path set in XDG_RUNTIME_DIR and the
  * socket name, must not exceed the maxium length of a Unix socket path.
  * The function also fails if the user do not have write permission in the
- * XDG_RUNTIME_DIR path or if the socket name is already in use.
+ * wayland socket path or if the socket name is already in use.
  *
  * \memberof wl_display
  */
-- 
2.1.0



More information about the wayland-devel mailing list