2 * Copyright © 2013 David Herrmann
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30 #include "compositor.h"
34 #if defined(HAVE_SYSTEMD_LOGIN) && defined(HAVE_DBUS)
36 #include <systemd/sd-login.h>
39 weston_logind_open(struct weston_logind *wl, const char *path,
43 weston_logind_close(struct weston_logind *wl, int fd);
46 weston_logind_restore(struct weston_logind *wl);
49 weston_logind_activate_vt(struct weston_logind *wl, int vt);
52 weston_logind_connect(struct weston_logind **out,
53 struct weston_compositor *compositor,
54 const char *seat_id, int tty);
57 weston_logind_destroy(struct weston_logind *wl);
60 weston_sd_session_get_vt(const char *sid, unsigned int *out)
62 #ifdef HAVE_SYSTEMD_LOGIN_209
63 return sd_session_get_vt(sid, out);
68 r = sd_session_get_tty(sid, &tty);
72 r = sscanf(tty, "tty%u", out);
82 #else /* defined(HAVE_SYSTEMD_LOGIN) && defined(HAVE_DBUS) */
85 weston_logind_open(struct weston_logind *wl, const char *path,
92 weston_logind_close(struct weston_logind *wl, int fd)
97 weston_logind_restore(struct weston_logind *wl)
102 weston_logind_activate_vt(struct weston_logind *wl, int vt)
108 weston_logind_connect(struct weston_logind **out,
109 struct weston_compositor *compositor,
110 const char *seat_id, int tty)
116 weston_logind_destroy(struct weston_logind *wl)
120 #endif /* defined(HAVE_SYSTEMD_LOGIN) && defined(HAVE_DBUS) */