diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-02-15 04:56:10 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-02-15 04:56:10 +0100 |
commit | fc8af9ff3fbbbf21bf26f21d2eb100f26afc201a (patch) | |
tree | 6fcdbdd6aa92862ed5b256b1bc6411809c7cfde9 /src | |
parent | 068665b6fd9839f27bcace7e8f56c0baa6935272 (diff) |
login: introduce sd_session_get_display()
Diffstat (limited to 'src')
-rw-r--r-- | src/login/libsystemd-login.sym | 1 | ||||
-rw-r--r-- | src/login/sd-login.c | 4 | ||||
-rw-r--r-- | src/login/test-login.c | 6 | ||||
-rw-r--r-- | src/systemd/sd-login.h | 3 |
4 files changed, 13 insertions, 1 deletions
diff --git a/src/login/libsystemd-login.sym b/src/login/libsystemd-login.sym index 2ae376da44..a5e6c1e756 100644 --- a/src/login/libsystemd-login.sym +++ b/src/login/libsystemd-login.sym @@ -44,4 +44,5 @@ LIBSYSTEMD_LOGIN_43 { global: sd_session_get_type; sd_session_get_class; + sd_session_get_display; } LIBSYSTEMD_LOGIN_38; diff --git a/src/login/sd-login.c b/src/login/sd-login.c index c100a7b4f2..887c421009 100644 --- a/src/login/sd-login.c +++ b/src/login/sd-login.c @@ -475,6 +475,10 @@ _public_ int sd_session_get_class(const char *session, char **class) { return session_get_string(session, "CLASS", class); } +_public_ int sd_session_get_display(const char *session, char **display) { + return session_get_string(session, "DISPLAY", display); +} + static int file_of_seat(const char *seat, char **_p) { char *p; int r; diff --git a/src/login/test-login.c b/src/login/test-login.c index 2aaa31f22f..dd8404285b 100644 --- a/src/login/test-login.c +++ b/src/login/test-login.c @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { int r, k; uid_t u, u2; - char *seat, *type, *class; + char *seat, *type, *class, *display; char *session; char *state; char *session2; @@ -83,6 +83,10 @@ int main(int argc, char* argv[]) { printf("class = %s\n", class); free(class); + assert_se(sd_session_get_display(session, &display) >= 0); + printf("display = %s\n", display); + free(display); + assert_se(sd_session_get_seat(session, &seat) >= 0); printf("seat = %s\n", seat); diff --git a/src/systemd/sd-login.h b/src/systemd/sd-login.h index 879e0744a8..2f3c90c129 100644 --- a/src/systemd/sd-login.h +++ b/src/systemd/sd-login.h @@ -96,6 +96,9 @@ int sd_session_get_type(const char *session, char **type); /* Determine the class of this session, i.e. one of "user", "greeter" or "lock-screen". */ int sd_session_get_class(const char *session, char **class); +/* Determine the X11 display of this session. */ +int sd_session_get_display(const char *session, char **display); + /* Return active session and user of seat */ int sd_seat_get_active(const char *seat, char **session, uid_t *uid); |