aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2014-01-22 11:54:01 +0100
committerLars Uebernickel <lars.uebernickel@canonical.com>2014-01-22 11:54:01 +0100
commite10669ba0b1e976a760cb34342da577e3db6c4f8 (patch)
treeb5a1078525d723e07296168f7670b06748aedc64 /src
parent12febda4ce88f9f319435ff1620e222365a05a29 (diff)
downloadayatana-indicator-power-e10669ba0b1e976a760cb34342da577e3db6c4f8.tar.gz
ayatana-indicator-power-e10669ba0b1e976a760cb34342da577e3db6c4f8.tar.bz2
ayatana-indicator-power-e10669ba0b1e976a760cb34342da577e3db6c4f8.zip
service.c: cache the control center command
Diffstat (limited to 'src')
-rw-r--r--src/service.c33
1 files changed, 20 insertions, 13 deletions
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