aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-02-21 16:39:47 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-02-27 16:29:25 +0100
commit2f800334533e49c7413a68816bf695db053e97c0 (patch)
treeb86c5495d1d7137b769482429c6c4c76a8785e8d
parent8265a6af696a084b92a32d32d2881d3e6f269c8b (diff)
downloadayatana-indicator-session-2f800334533e49c7413a68816bf695db053e97c0.tar.gz
ayatana-indicator-session-2f800334533e49c7413a68816bf695db053e97c0.tar.bz2
ayatana-indicator-session-2f800334533e49c7413a68816bf695db053e97c0.zip
src/utils.(c|h): Add get_desktop_session() helper function.
Signed-off-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
-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__ */