From 572dfcdba7694dc2221dcab2ed8b57615d59ed83 Mon Sep 17 00:00:00 2001 From: random human Date: Tue, 18 Sep 2018 04:48:35 +0530 Subject: Add support for WLR_SESSION env variable Valid values are "logind"/"systemd" and "direct". If WLR_SESSION is set, only its value is potentially tried; it will not try any other option. --- backend/session/session.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'backend/session') diff --git a/backend/session/session.c b/backend/session/session.c index 3fcac3e3..041d8f83 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -66,10 +66,25 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_session *wlr_session_create(struct wl_display *disp) { struct wlr_session *session = NULL; - const struct session_impl **iter; - for (iter = impls; !session && *iter; ++iter) { - session = (*iter)->create(disp); + const char *env_wlr_session = getenv("WLR_SESSION"); + if (env_wlr_session) { + if (!strcmp(env_wlr_session, "logind") || !strcmp(env_wlr_session, "systemd")) { + #if defined(WLR_HAS_SYSTEMD) || defined(WLR_HAS_ELOGIND) + session = session_logind.create(disp); + #else + wlr_log(WLR_ERROR, "wlroots is not compiled with logind support"); + #endif + } else if (!strcmp(env_wlr_session, "direct")) { + session = session_direct.create(disp); + } else { + wlr_log(WLR_ERROR, "WLR_SESSION has an invalid value: %s", env_wlr_session); + } + } else { + const struct session_impl **iter; + for (iter = impls; !session && *iter; ++iter) { + session = (*iter)->create(disp); + } } if (!session) { -- cgit v1.2.3