From 26aff210586479ae5d40f101633c96c0d4f670e3 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sun, 23 Aug 2020 20:13:05 +0200 Subject: logind: Set session type from env --- libseat/backend/logind.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libseat/backend/logind.c') diff --git a/libseat/backend/logind.c b/libseat/backend/logind.c index 415553c..9f4eabc 100644 --- a/libseat/backend/logind.c +++ b/libseat/backend/logind.c @@ -26,6 +26,7 @@ #include "backend.h" #include "drm.h" #include "libseat.h" +#include "log.h" struct backend_logind { struct libseat base; @@ -690,6 +691,22 @@ error: return false; } +static int set_type(struct backend_logind *backend, const char *type) { + sd_bus_message *msg = NULL; + sd_bus_error error = SD_BUS_ERROR_NULL; + + int ret = sd_bus_call_method(backend->bus, "org.freedesktop.login1", backend->path, + "org.freedesktop.login1.Session", "SetType", &error, &msg, "s", + type); + if (ret < 0) { + log_errorf("unable to set session type: %s", error.message); + } + + sd_bus_error_free(&error); + sd_bus_message_unref(msg); + return ret; +} + static struct libseat *logind_open_seat(struct libseat_seat_listener *listener, void *data) { struct backend_logind *backend = calloc(1, sizeof(struct backend_logind)); if (backend == NULL) { @@ -737,6 +754,11 @@ static struct libseat *logind_open_seat(struct libseat_seat_listener *listener, } } + const char *env = getenv("XDG_SESSION_TYPE"); + if (env != NULL) { + set_type(backend, env); + } + backend->initial_setup = true; backend->active = true; backend->seat_listener = listener; -- cgit v1.2.3