mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
session/logind: check for XDG_SESSION_ID first
In order to support compositors running as systemd user units without display manager,
a mechanism for specifying session ID exactly must exist.
Checking for `XDG_SESSION_ID` mimics loginctl behaviour e95be7def2/src/login/loginctl.c (L856)
.
This commit is contained in:
parent
aa39dbd1e7
commit
151b7d1d94
1 changed files with 14 additions and 3 deletions
|
@ -538,15 +538,26 @@ static bool get_display_session(char **session_id) {
|
||||||
assert(session_id != NULL);
|
assert(session_id != NULL);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
char *type = NULL;
|
||||||
|
char *state = NULL;
|
||||||
|
char *xdg_session_id = getenv("XDG_SESSION_ID");
|
||||||
|
|
||||||
|
if (xdg_session_id) {
|
||||||
|
// This just checks whether the supplied session ID is valid
|
||||||
|
if (sd_session_is_active(xdg_session_id) < 0) {
|
||||||
|
wlr_log(WLR_ERROR, "Invalid XDG_SESSION_ID: '%s'", xdg_session_id);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
*session_id = strdup(xdg_session_id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// If there's a session active for the current process then just use that
|
// If there's a session active for the current process then just use that
|
||||||
ret = sd_pid_get_session(getpid(), session_id);
|
ret = sd_pid_get_session(getpid(), session_id);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *type = NULL;
|
|
||||||
char *state = NULL;
|
|
||||||
|
|
||||||
// Find any active sessions for the user if the process isn't part of an
|
// Find any active sessions for the user if the process isn't part of an
|
||||||
// active session itself
|
// active session itself
|
||||||
ret = sd_uid_get_display(getuid(), session_id);
|
ret = sd_uid_get_display(getuid(), session_id);
|
||||||
|
|
Loading…
Reference in a new issue