diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2014-09-20 18:42:29 +0200 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2014-09-22 14:27:02 +0200 |
commit | c72d5456e2d6a6c8cefbfc16a542ae03a769397f (patch) | |
tree | 2fdd3fd00a04984c20df04bd9c573b659a84fa65 /src | |
parent | 7f3d3ba1a61f28a951ca5fbe59ed15c7ce55219c (diff) |
login: add public sd_session_get_desktop() API
The desktop brand is stored as DESKTOP variable for sessions. It can be
set arbitrarily by the session owner and identifies the desktop
environment that is running on that session.
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/libsystemd.sym.m4 | 7 | ||||
-rw-r--r-- | src/libsystemd/sd-login/sd-login.c | 19 | ||||
-rw-r--r-- | src/systemd/sd-login.h | 3 |
3 files changed, 28 insertions, 1 deletions
diff --git a/src/libsystemd/libsystemd.sym.m4 b/src/libsystemd/libsystemd.sym.m4 index d1450fbb26..87da7ac021 100644 --- a/src/libsystemd/libsystemd.sym.m4 +++ b/src/libsystemd/libsystemd.sym.m4 @@ -153,6 +153,11 @@ global: sd_machine_get_ifindices; } LIBSYSTEMD_214; +LIBSYSTEMD_217 { +global: + sd_session_get_desktop; +} LIBSYSTEMD_216; + m4_ifdef(`ENABLE_KDBUS', LIBSYSTEMD_FUTURE { global: @@ -438,5 +443,5 @@ global: /* sd-path */ sd_path_home; sd_path_search; -} LIBSYSTEMD_216; +} LIBSYSTEMD_217; ) diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c index 95cb6ff581..c72d23ed53 100644 --- a/src/libsystemd/sd-login/sd-login.c +++ b/src/libsystemd/sd-login/sd-login.c @@ -485,6 +485,25 @@ _public_ int sd_session_get_class(const char *session, char **class) { return session_get_string(session, "CLASS", class); } +_public_ int sd_session_get_desktop(const char *session, char **desktop) { + _cleanup_free_ char *escaped = NULL; + char *t; + int r; + + assert_return(desktop, -EINVAL); + + r = session_get_string(session, "DESKTOP", &escaped); + if (r < 0) + return r; + + t = cunescape(escaped); + if (!t) + return -ENOMEM; + + *desktop = t; + return 0; +} + _public_ int sd_session_get_display(const char *session, char **display) { return session_get_string(session, "DISPLAY", display); } diff --git a/src/systemd/sd-login.h b/src/systemd/sd-login.h index 1eb3be30b5..93af19709b 100644 --- a/src/systemd/sd-login.h +++ b/src/systemd/sd-login.h @@ -147,6 +147,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 **clazz); +/* Determine the desktop brand of this session, i.e. something like "GNOME", "KDE" or "SYSTEMD-CONSOLE". */ +int sd_session_get_desktop(const char *session, char **desktop); + /* Determine the X11 display of this session. */ int sd_session_get_display(const char *session, char **display); |