mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-09 03:38:03 +02:00
launcher-logind: Try the user's primary session if not in a session
If we're not in a session we can fall back to sd_uid_get_display() to find the user's primary session. This allows launching weston from an ssh session or as a systemd user service if a viable session is available. It also more closely follows how libseat finds the session. The libseat launcher can already do these things, so this change makes these features common to both launchers. Based on a patch by Sjoerd Simons <sjoerd.simons@collabora.com> Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
parent
d2a320d53e
commit
b6c891774e
1 changed files with 25 additions and 4 deletions
|
|
@ -734,6 +734,29 @@ launcher_logind_activate(struct launcher_logind *wl)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
launcher_logind_get_session(char **session)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = sd_pid_get_session(getpid(), session);
|
||||
if (r < 0) {
|
||||
if (r != -ENODATA) {
|
||||
weston_log("logind: not running in a systemd session: %d\n", r);
|
||||
return r;
|
||||
}
|
||||
} else {
|
||||
return r;
|
||||
}
|
||||
|
||||
/* When not inside a systemd session look if there is a suitable one */
|
||||
r = sd_uid_get_display(getuid(), session);
|
||||
if (r < 0)
|
||||
weston_log("logind: cannot find systemd session for uid: %d %d\n", getuid(), r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int
|
||||
launcher_logind_connect(struct weston_launcher **out, struct weston_compositor *compositor,
|
||||
int tty, const char *seat_id, bool sync_drm)
|
||||
|
|
@ -759,11 +782,9 @@ launcher_logind_connect(struct weston_launcher **out, struct weston_compositor *
|
|||
goto err_wl;
|
||||
}
|
||||
|
||||
r = sd_pid_get_session(getpid(), &wl->sid);
|
||||
if (r < 0) {
|
||||
weston_log("logind: not running in a systemd session\n");
|
||||
r = launcher_logind_get_session(&wl->sid);
|
||||
if (r < 0)
|
||||
goto err_seat;
|
||||
}
|
||||
|
||||
t = NULL;
|
||||
r = sd_session_get_seat(wl->sid, &t);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue