[PATCH v3 1/6] libweston: set the seat automatically based on the XDG_SEAT environment variable

nerdopolis bluescreen_avenger at verizon.net
Sun Oct 8 02:01:01 UTC 2017


This will allow the seat to be set by the environment as pam_systemd typically
sets the XDG_SEAT variable
---
 compositor/main.c          | 2 +-
 libweston/compositor-drm.c | 5 +++++
 man/weston-drm.man         | 7 +++++--
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 0615d87e..61bda282 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -562,7 +562,7 @@ usage(int error_code)
 #if defined(BUILD_DRM_COMPOSITOR)
 	fprintf(stderr,
 		"Options for drm-backend.so:\n\n"
-		"  --seat=SEAT\t\tThe seat that weston should run on\n"
+		"  --seat=SEAT\t\tThe seat that weston should run on, instead of the seat defined in XDG_SEAT\n"
 		"  --tty=TTY\t\tThe tty to use\n"
 		"  --use-pixman\t\tUse the pixman (CPU) renderer\n"
 		"  --current-mode\tPrefer current KMS mode over EDID preferred mode\n\n");
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index b641d61e..0025f5ba 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -4002,8 +4002,13 @@ drm_backend_create(struct weston_compositor *compositor,
 	struct udev_device *drm_device;
 	struct wl_event_loop *loop;
 	const char *seat_id = default_seat;
+	const char *session_seat;
 	int ret;
 
+	session_seat = getenv("XDG_SEAT");
+	if (session_seat)
+		seat_id = session_seat;
+
 	weston_log("initializing drm backend\n");
 
 	b = zalloc(sizeof *b);
diff --git a/man/weston-drm.man b/man/weston-drm.man
index d7fd5614..17c1ad31 100644
--- a/man/weston-drm.man
+++ b/man/weston-drm.man
@@ -94,8 +94,8 @@ switching to the monitor preferred mode.
 \fB\-\-seat\fR=\fIseatid\fR
 Use graphics and input devices designated for seat
 .I seatid
-instead of the default seat
-.BR seat0 .
+instead of the seat defined in the environment variable
+. BR XDG_SEAT " , and If neither is specifed, seat0 will be assumed."
 .TP
 \fB\-\-tty\fR=\fIx\fR
 Launch Weston on tty
@@ -117,6 +117,9 @@ The file descriptor (integer) where
 .B weston-launch
 is listening. Automatically set by
 .BR weston-launch .
+.TP
+.B XDG_SEAT
+The seat that Weston will start on.
 .
 .\" ***************************************************************
 .SH "SEE ALSO"
-- 
2.14.1



More information about the wayland-devel mailing list