[gnome-settings-daemon] power: Add way to disable the backlight helper



commit a1a2ed565cb1e9989bf368bbcdb7820480e6b7cd
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jan 23 23:08:55 2013 +0100

    power: Add way to disable the backlight helper
    
    Otherwise, on a machine with kernel provided brightness object,
    the test suite will try to use the real machine's brightness.

 plugins/power/gpm-common.c |   19 +++++++++++++++++++
 plugins/power/test.py      |    1 +
 2 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/plugins/power/gpm-common.c b/plugins/power/gpm-common.c
index eb64fce..2fcb0d2 100644
--- a/plugins/power/gpm-common.c
+++ b/plugins/power/gpm-common.c
@@ -1175,6 +1175,21 @@ out:
         return output;
 }
 
+static gboolean
+backlight_helper_disabled (void)
+{
+        const char *disable_backlight;
+
+        disable_backlight = g_getenv ("GSD_DISABLE_BACKLIGHT_HELPER");
+        if (disable_backlight) {
+                int disabled;
+                disabled = atoi (disable_backlight);
+                if (disabled > 0)
+                        return TRUE;
+        }
+        return FALSE;
+}
+
 /**
  * backlight_helper_get_value:
  *
@@ -1201,6 +1216,8 @@ backlight_helper_get_value (const gchar *argument, GError **error)
                              "The sysfs backlight helper is only for Linux");
         goto out;
 #endif
+        if (backlight_helper_disabled ())
+                goto out;
 
         /* get the data */
         command = g_strdup_printf (LIBEXECDIR "/gsd-backlight-helper --%s",
@@ -1289,6 +1306,8 @@ backlight_helper_set_value (const gchar *argument,
                              "The sysfs backlight helper is only for Linux");
         goto out;
 #endif
+        if (backlight_helper_disabled ())
+                goto out;
 
         /* get the data */
         command = g_strdup_printf ("pkexec " LIBEXECDIR "/gsd-backlight-helper --%s %i",
diff --git a/plugins/power/test.py b/plugins/power/test.py
index 98e3a1a..b6d6d11 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -62,6 +62,7 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
         # avoid painfully long delays of actions for tests
         env = os.environ.copy()
         env['GSD_ACTION_DELAY'] = '1'
+        env['GSD_DISABLE_BACKLIGHT_HELPER'] = '1'
         self.daemon = subprocess.Popen(
             [os.path.join(builddir, 'gsd-test-power')],
             # comment out this line if you want to see the logs in real time



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]