1SD_SESSION_IS_ACTIVE(3) sd_session_is_active SD_SESSION_IS_ACTIVE(3)
2
3
4
6 sd_session_is_active, sd_session_is_remote, sd_session_get_state,
7 sd_session_get_uid, sd_session_get_seat, sd_session_get_service,
8 sd_session_get_type, sd_session_get_class, sd_session_get_desktop,
9 sd_session_get_display, sd_session_get_tty, sd_session_get_vt,
10 sd_session_get_remote_host, sd_session_get_remote_user - Determine
11 state of a specific session
12
14 #include <systemd/sd-login.h>
15
16 int sd_session_is_active(const char *session);
17
18 int sd_session_is_remote(const char *session);
19
20 int sd_session_get_state(const char *session, char **state);
21
22 int sd_session_get_uid(const char *session, uid_t *uid);
23
24 int sd_session_get_seat(const char *session, char **seat);
25
26 int sd_session_get_service(const char *session, char **service);
27
28 int sd_session_get_type(const char *session, char **type);
29
30 int sd_session_get_class(const char *session, char **class);
31
32 int sd_session_get_desktop(const char *session, char **desktop);
33
34 int sd_session_get_display(const char *session, char **display);
35
36 int sd_session_get_remote_host(const char *session,
37 char **remote_host);
38
39 int sd_session_get_remote_user(const char *session,
40 char **remote_user);
41
42 int sd_session_get_tty(const char *session, char **tty);
43
44 int sd_session_get_vt(const char *session, unsigned int *vt);
45
47 sd_session_is_active() may be used to determine whether the session
48 identified by the specified session identifier is currently active
49 (i.e. currently in the foreground and available for user input) or not.
50
51 sd_session_is_remote() may be used to determine whether the session
52 identified by the specified session identifier is a remote session
53 (i.e. its remote host is known) or not.
54
55 sd_session_get_state() may be used to determine the state of the
56 session identified by the specified session identifier. The following
57 states are currently known: "online" (session logged in, but session
58 not active, i.e. not in the foreground), "active" (session logged in
59 and active, i.e. in the foreground), "closing" (session nominally
60 logged out, but some processes belonging to it are still around). In
61 the future additional states might be defined, client code should be
62 written to be robust in regards to additional state strings being
63 returned. This function is a more generic version of
64 sd_session_is_active(). The returned string needs to be freed with the
65 libc free(3) call after use.
66
67 sd_session_get_uid() may be used to determine the user identifier of
68 the Unix user the session identified by the specified session
69 identifier belongs to.
70
71 sd_session_get_seat() may be used to determine the seat identifier of
72 the seat the session identified by the specified session identifier
73 belongs to. Note that not all sessions are attached to a seat, this
74 call will fail (returning -ENODATA) for them. The returned string needs
75 to be freed with the libc free(3) call after use.
76
77 sd_session_get_service() may be used to determine the name of the
78 service (as passed during PAM session setup) that registered the
79 session identified by the specified session identifier. The returned
80 string needs to be freed with the libc free(3) call after use.
81
82 sd_session_get_type() may be used to determine the type of the session
83 identified by the specified session identifier. The returned string is
84 one of "x11", "wayland", "tty", "mir" or "unspecified" and needs to be
85 freed with the libc free(3) call after use.
86
87 sd_session_get_class() may be used to determine the class of the
88 session identified by the specified session identifier. The returned
89 string is one of "user", "greeter", "lock-screen", or "background" and
90 needs to be freed with the libc free(3) call after use.
91
92 sd_session_get_desktop() may be used to determine the brand of the
93 desktop running on the session identified by the specified session
94 identifier. This field can be set freely by desktop environments and
95 does not follow any special formatting. However, desktops are strongly