mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-26 14:45:58 +01:00
Merge pull request #37 from acrisci/bug/session-path
Correctly get session path
This commit is contained in:
commit
5743ea03b8
1 changed files with 36 additions and 11 deletions
|
@ -124,6 +124,36 @@ static bool logind_change_vt(struct wlr_session *base, unsigned vt) {
|
||||||
return ret >= 0;
|
return ret >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool find_sesion_path(struct logind_session *session) {
|
||||||
|
int ret;
|
||||||
|
sd_bus_message *msg = NULL;
|
||||||
|
sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||||
|
|
||||||
|
ret = sd_bus_call_method(session->bus, "org.freedesktop.login1",
|
||||||
|
"/org/freedesktop/login1", "org.freedesktop.login1.Manager",
|
||||||
|
"GetSession", &error, &msg, "s", session->id);
|
||||||
|
if (ret < 0) {
|
||||||
|
wlr_log(L_ERROR, "Failed to get session path: %s", strerror(-ret));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *path;
|
||||||
|
|
||||||
|
ret = sd_bus_message_read(msg, "o", &path);
|
||||||
|
if (ret < 0) {
|
||||||
|
wlr_log(L_ERROR, "Could not parse session path: %s", strerror(-ret));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
session->path = strdup(path);
|
||||||
|
|
||||||
|
out:
|
||||||
|
sd_bus_error_free(&error);
|
||||||
|
sd_bus_message_unref(msg);
|
||||||
|
|
||||||
|
return ret >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
static bool session_activate(struct logind_session *session) {
|
static bool session_activate(struct logind_session *session) {
|
||||||
int ret;
|
int ret;
|
||||||
sd_bus_message *msg = NULL;
|
sd_bus_message *msg = NULL;
|
||||||
|
@ -315,22 +345,17 @@ static struct wlr_session *logind_session_start(struct wl_display *disp) {
|
||||||
snprintf(session->base.seat, sizeof(session->base.seat), "%s", seat);
|
snprintf(session->base.seat, sizeof(session->base.seat), "%s", seat);
|
||||||
free(seat);
|
free(seat);
|
||||||
|
|
||||||
const char *fmt = "/org/freedesktop/login1/session/%s";
|
|
||||||
int len = snprintf(NULL, 0, fmt, session->id);
|
|
||||||
|
|
||||||
session->path = malloc(len + 1);
|
|
||||||
if (!session->path) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(session->path, fmt, session->id);
|
|
||||||
|
|
||||||
ret = sd_bus_default_system(&session->bus);
|
ret = sd_bus_default_system(&session->bus);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wlr_log(L_ERROR, "Failed to open D-Bus connection: %s", strerror(-ret));
|
wlr_log(L_ERROR, "Failed to open D-Bus connection: %s", strerror(-ret));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!find_sesion_path(session)) {
|
||||||
|
sd_bus_unref(session->bus);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (!add_signal_matches(session)) {
|
if (!add_signal_matches(session)) {
|
||||||
goto error_bus;
|
goto error_bus;
|
||||||
}
|
}
|
||||||
|
@ -357,9 +382,9 @@ static struct wlr_session *logind_session_start(struct wl_display *disp) {
|
||||||
|
|
||||||
error_bus:
|
error_bus:
|
||||||
sd_bus_unref(session->bus);
|
sd_bus_unref(session->bus);
|
||||||
|
free(session->path);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
free(session->path);
|
|
||||||
free(session->id);
|
free(session->id);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue