diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-02-21 16:39:47 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-02-27 16:29:25 +0100 |
commit | 2f800334533e49c7413a68816bf695db053e97c0 (patch) | |
tree | b86c5495d1d7137b769482429c6c4c76a8785e8d | |
parent | 8265a6af696a084b92a32d32d2881d3e6f269c8b (diff) | |
download | ayatana-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.c | 24 | ||||
-rw-r--r-- | src/utils.h | 1 |
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__ */ |