[PATCH wayland] Introduce WAYLAND_SERVER_SOCKET_DIR to change socket directory without changing XDG_RUNTIME_DIR.

Davide Bettio davide.bettio at ispirata.com
Tue Jul 28 08:54:32 PDT 2015


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.

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

diff --git a/src/wayland-server.c b/src/wayland-server.c
index d73792a..5ed4a8b 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -1098,9 +1098,13 @@ 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: Neither XDG_RUNTIME_DIR nor WAYLAND_SERVER_SOCKET_DIR 
have
+                        been set in the environment\n");

  		/* to prevent programs reporting
  		 * "failed to add socket: Success" */
@@ -1225,14 +1229,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