aboutsummaryrefslogtreecommitdiff
path: root/libseat
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-08-23 20:13:05 +0200
committerKenny Levinsen <kl@kl.wtf>2020-08-23 20:13:05 +0200
commit26aff210586479ae5d40f101633c96c0d4f670e3 (patch)
tree133ff09929867e2111c13f6824e973e97d01b7e4 /libseat
parent8ab3fc03aacf202f4d73b61f7c982e6ffca8312e (diff)
logind: Set session type from env
Diffstat (limited to 'libseat')
-rw-r--r--libseat/backend/logind.c22
1 files changed, 22 insertions, 0 deletions
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;