aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-03-12 19:10:48 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-03-12 19:11:00 +0100
commit1830c84a2b95ca4b840a65317e75a609b33c3512 (patch)
treee8a837eac2c3494d467731f0a962a92bc3364bfd /src/utils.c
parent4774ba8cbe14396cc653a4370cb9a49905efb3ff (diff)
downloadayatana-indicator-power-1830c84a2b95ca4b840a65317e75a609b33c3512.tar.gz
ayatana-indicator-power-1830c84a2b95ca4b840a65317e75a609b33c3512.tar.bz2
ayatana-indicator-power-1830c84a2b95ca4b840a65317e75a609b33c3512.zip
src/utils.(c|h): Port is_{mate,gnome,unity}() functions from -session indicator.
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index 6b2aeb3..ad6d510 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -83,3 +83,66 @@ utils_handle_settings_request (void)
execute_command (control_center_cmd);
}
+
+gboolean
+is_unity ()
+{
+ const gchar *xdg_current_desktop;
+ gchar **desktop_names;
+ int i;
+
+ xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
+ if (xdg_current_desktop != NULL) {
+ desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
+ for (i = 0; desktop_names[i]; ++i) {
+ if (!g_strcmp0 (desktop_names[i], "Unity")) {
+ g_strfreev (desktop_names);
+ return TRUE;
+ }
+ }
+ g_strfreev (desktop_names);
+ }
+ return FALSE;
+}
+
+gboolean
+is_gnome ()
+{
+ const gchar *xdg_current_desktop;
+ gchar **desktop_names;
+ int i;
+
+ xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
+ if (xdg_current_desktop != NULL) {
+ desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
+ for (i = 0; desktop_names[i]; ++i) {
+ if (!g_strcmp0 (desktop_names[i], "GNOME")) {
+ g_strfreev (desktop_names);
+ return TRUE;
+ }
+ }
+ g_strfreev (desktop_names);
+ }
+ return FALSE;
+}
+
+gboolean
+is_mate ()
+{
+ const gchar *xdg_current_desktop;
+ gchar **desktop_names;
+ int i;
+
+ xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
+ if (xdg_current_desktop != NULL) {
+ desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
+ for (i = 0; desktop_names[i]; ++i) {
+ if (!g_strcmp0 (desktop_names[i], "MATE")) {
+ g_strfreev (desktop_names);
+ return TRUE;
+ }
+ }
+ g_strfreev (desktop_names);
+ }
+ return FALSE;
+}