From fd8313fc612e355726546a5155c950e16040c134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Steinbei=C3=9F?= Date: Tue, 21 Jan 2014 18:40:02 +0100 Subject: Add support for opening xfce4-powermanager-settings when in a Xubuntu-session --- src/service.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/service.c') diff --git a/src/service.c b/src/service.c index fe69c6d..7fead79 100644 --- a/src/service.c +++ b/src/service.c @@ -693,12 +693,16 @@ on_settings_activated (GSimpleAction * a G_GNUC_UNUSED, gpointer gself G_GNUC_UNUSED) { gchar *path; - - path = g_find_program_in_path ("unity-control-center"); - if (path != NULL) - execute_command ("unity-control-center power"); - else - execute_command ("gnome-control-center power"); + if (!g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity")) + { + path = g_find_program_in_path ("unity-control-center"); + if (path != NULL) + execute_command ("unity-control-center power"); + else + execute_command ("gnome-control-center power"); + } + else if (!g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "xubuntu")) + execute_command ("xfce4-power-manager-settings"); g_free (path); } -- cgit v1.2.3 From 2f5e7c9b93ea31fd7a123c845bc0e9a3632f4903 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 22 Jan 2014 11:43:00 +0100 Subject: service.c: remove free() on uninitialized pointer --- src/service.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/service.c') diff --git a/src/service.c b/src/service.c index 7fead79..a2fc638 100644 --- a/src/service.c +++ b/src/service.c @@ -692,18 +692,20 @@ on_settings_activated (GSimpleAction * a G_GNUC_UNUSED, GVariant * param G_GNUC_UNUSED, gpointer gself G_GNUC_UNUSED) { - gchar *path; if (!g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity")) { + gchar *path; + path = g_find_program_in_path ("unity-control-center"); if (path != NULL) execute_command ("unity-control-center power"); else execute_command ("gnome-control-center power"); + + g_free (path); } else if (!g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "xubuntu")) execute_command ("xfce4-power-manager-settings"); - g_free (path); } static void -- cgit v1.2.3 From 12febda4ce88f9f319435ff1620e222365a05a29 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 22 Jan 2014 11:46:36 +0100 Subject: service.c: execute unity-control-center on desktops other than unity as well The fallback session uses the indicators as well but doesn't have $XDG_CURRENT_DESKTOP set to "Unity". --- src/service.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/service.c') diff --git a/src/service.c b/src/service.c index a2fc638..ab5deb5 100644 --- a/src/service.c +++ b/src/service.c @@ -692,7 +692,11 @@ on_settings_activated (GSimpleAction * a G_GNUC_UNUSED, GVariant * param G_GNUC_UNUSED, gpointer gself G_GNUC_UNUSED) { - if (!g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity")) + if (!g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "xubuntu")) + { + execute_command ("xfce4-power-manager-settings"); + } + else { gchar *path; @@ -704,8 +708,6 @@ on_settings_activated (GSimpleAction * a G_GNUC_UNUSED, g_free (path); } - else if (!g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "xubuntu")) - execute_command ("xfce4-power-manager-settings"); } static void -- cgit v1.2.3 From e10669ba0b1e976a760cb34342da577e3db6c4f8 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 22 Jan 2014 11:54:01 +0100 Subject: service.c: cache the control center command --- src/service.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'src/service.c') diff --git a/src/service.c b/src/service.c index ab5deb5..982a24e 100644 --- a/src/service.c +++ b/src/service.c @@ -692,22 +692,29 @@ on_settings_activated (GSimpleAction * a G_GNUC_UNUSED, GVariant * param G_GNUC_UNUSED, gpointer gself G_GNUC_UNUSED) { - if (!g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "xubuntu")) + static const gchar *control_center_cmd = NULL; + + if (control_center_cmd == NULL) { - execute_command ("xfce4-power-manager-settings"); - } - else - { - gchar *path; + if (!g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "xubuntu")) + { + control_center_cmd = "xfce4-power-manager-settings"; + } + else + { + gchar *path; - path = g_find_program_in_path ("unity-control-center"); - if (path != NULL) - execute_command ("unity-control-center power"); - else - execute_command ("gnome-control-center power"); + path = g_find_program_in_path ("unity-control-center"); + if (path != NULL) + control_center_cmd = "unity-control-center power"; + else + control_center_cmd = "gnome-control-center power"; - g_free (path); - } + g_free (path); + } + } + + execute_command (control_center_cmd); } static void -- cgit v1.2.3