aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/utils.c24
-rw-r--r--src/utils.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index 991f4ec..8c69a59 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -152,3 +152,27 @@ get_desktop_name (void)
return desktop_name;
}
+
+const char*
+get_desktop_session (void)
+{
+ static const char * desktop_session = NULL;
+ const char * xdg_desktop_session;
+
+ if (desktop_session == NULL)
+ {
+ xdg_desktop_session = g_getenv ("XDG_DESKTOP_SESSION");
+
+ if (xdg_desktop_session == NULL)
+ {
+ /* try DESKTOP_SESSION env var if XDG_DESKTOP_SESSION is unset */
+ desktop_session = g_getenv ("DESKTOP_SESSION");
+ }
+ else
+ {
+ desktop_session = xdg_desktop_session;
+ }
+ }
+
+ return desktop_session;
+}
diff --git a/src/utils.h b/src/utils.h
index 149087b..d57eebe 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -24,6 +24,7 @@ const char* get_distro_name();
const char* get_distro_url();
const char* get_distro_bts_url();
const char* get_desktop_name();
+const char* get_desktop_session();
GHashTable* get_os_release();
#endif /* __INDICATOR_SESSION_UTILS_H__ */