Re: [gpm] gnome-power-manager and DPMS



On Sun, 2006-07-30 at 12:06 +0100, William Waghorn wrote:
> Richard Hughes wrote:
> > How does that sound?
> >   
> Yes, that sound perfectly acceptable and will certainly address my own
> problem.  It is also somewhat simpler than my new patch (for what its
> worth, appended to this message), which adds a pair of textual gconf
> keys; one for battery, and one for AC.  Seems to me like laptop users
> might want to choose different power-down states depending on whether
> they're running on battery or not.  However I'll admit this is overkill.

Hmm, my patch is simple, but yours has the advantage it can be used to
fix other dpms bugs that may or may not exist yet ;-)

I've modified your patch slightly and committed to CVS HEAD.
I've attached the modified patch to show you how I modified it.

Many thanks for your work tracking down the problem,

Richard.

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/ChangeLog,v
retrieving revision 1.643
diff -u -u -r1.643 ChangeLog
--- ChangeLog	30 Jul 2006 11:05:14 -0000	1.643
+++ ChangeLog	30 Jul 2006 12:48:26 -0000
@@ -1,5 +1,20 @@
 2006-07-30  Richard Hughes  <richard hughsie com>
 
+	Commit a slightly modified patch from
+	William Waghorn <willw litany me uk> many thanks.
+
+	* data/gnome-power-manager.schemas.in:
+	* src/gpm-manager.c:
+	* src/gpm-prefs.h:
+	Add in two new gconf keys battery_dpms_sleep_method and
+	ac_dpms_sleep_method to support systems that only support a specific
+	DPMS sleep mode.
+
+	* docs/faq.xml:
+	Add a entry about the dpms sleep modes and broken monitors.
+
+2006-07-30  Richard Hughes  <richard hughsie com>
+
 	* data/gnome-power-manager.schemas.in:
 	Make a difficult to translate string easier to understand.
 
Index: data/gnome-power-manager.schemas.in
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/data/gnome-power-manager.schemas.in,v
retrieving revision 1.37
diff -u -u -r1.37 gnome-power-manager.schemas.in
--- data/gnome-power-manager.schemas.in	30 Jul 2006 11:05:14 -0000	1.37
+++ data/gnome-power-manager.schemas.in	30 Jul 2006 12:48:28 -0000
@@ -274,6 +274,17 @@
    </schema>
 
     <schema>
+      <key>/schemas/apps/gnome-power-manager/ac_dpms_sleep_method</key>
+      <applyto>/apps/gnome-power-manager/ac_dpms_sleep_method</applyto>
+      <type>string</type>
+      <default>default</default>
+      <locale name="C">
+        <short>Method used to blank screen on AC</short>
+        <long>The DPMS method used to blank the screen when on AC power. Possible values are "default", "standby", "suspend" and "off".</long>
+      </locale>
+   </schema>
+
+    <schema>
       <key>/schemas/apps/gnome-power-manager/battery_brightness</key>
       <applyto>/apps/gnome-power-manager/battery_brightness</applyto>
       <type>int</type>
@@ -305,7 +316,18 @@
         <long>The amount of time in seconds the computer on battery power needs to be inactive before the display goes to sleep.</long>
       </locale>
    </schema>
-   
+
+    <schema>
+      <key>/schemas/apps/gnome-power-manager/battery_dpms_sleep_method</key>
+      <applyto>/apps/gnome-power-manager/battery_dpms_sleep_method</applyto>
+      <type>string</type>
+      <default>default</default>
+      <locale name="C">
+        <short>Method used to blank screen on battery</short>
+        <long>The DPMS method used to blank the screen when on battery power. Possible values are "default", "standby", "suspend" and "off".</long>
+      </locale>
+   </schema>
+
     <schema>
       <key>/schemas/apps/gnome-power-manager/action_button_suspend</key>
       <applyto>/apps/gnome-power-manager/action_button_suspend</applyto>
Index: docs/faq.xml
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/docs/faq.xml,v
retrieving revision 1.2
diff -u -u -r1.2 faq.xml
--- docs/faq.xml	18 Jun 2006 21:14:24 -0000	1.2
+++ docs/faq.xml	30 Jul 2006 12:48:28 -0000
@@ -12,6 +12,22 @@
       the mailing list.
     </para>
 
+    <sect2 id="faq-dpms-broken-monitor">
+      <title>
+        My monitor is broken and treats DPMS standby and off states as
+        'no-signal' which leaves the monitor powered on.
+      </title>
+
+      <para>
+        You have to change the dpms suspend mode gnome-power-manager uses.
+        Open gconf-editor, and then change the keys 
+        <literal>/apps/gnome-power-manager/ac_dpms_sleep_method</literal> and
+        <literal>/apps/gnome-power-manager/battery_dpms_sleep_method</literal>
+        to one of the modes that work, e.g. standby, suspend or off.
+      </para>
+
+    </sect2>
+
     <sect2 id="faq-longer-suspend">
       <title>
         I've set the computer inactive timeout to one minute and it still
Index: src/gpm-manager.c
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/src/gpm-manager.c,v
retrieving revision 1.161
diff -u -u -r1.161 gpm-manager.c
--- src/gpm-manager.c	20 Jul 2006 21:23:58 -0000	1.161
+++ src/gpm-manager.c	30 Jul 2006 12:48:28 -0000
@@ -528,25 +528,33 @@
 static void
 sync_dpms_policy (GpmManager *manager)
 {
-	GError  *error;
-	gboolean res;
-	gboolean on_ac;
-	guint    standby;
-	guint    suspend;
-	guint    off;
+	GError     *error;
+	gboolean    res;
+	gboolean    on_ac;
+	guint       timeout;
+	guint       standby;
+	guint       suspend;
+	guint       off;
+	const char *dpms_method;
 
 	error = NULL;
 
 	gpm_power_get_on_ac (manager->priv->power, &on_ac, NULL);
 
 	if (on_ac) {
-		standby = gconf_client_get_int (manager->priv->gconf_client,
+		timeout = gconf_client_get_int (manager->priv->gconf_client,
 						GPM_PREF_AC_SLEEP_DISPLAY,
 						&error);
+		dpms_method = gconf_client_get_string (manager->priv->gconf_client,
+						       GPM_PREF_AC_DPMS_METHOD,
+						       &error);
 	} else {
-		standby = gconf_client_get_int (manager->priv->gconf_client,
+		timeout = gconf_client_get_int (manager->priv->gconf_client,
 						GPM_PREF_BATTERY_SLEEP_DISPLAY,
 						&error);
+		dpms_method = gconf_client_get_string (manager->priv->gconf_client,
+						       GPM_PREF_BATTERY_DPMS_METHOD,
+						       &error);
 	}
 
 	if (error) {
@@ -556,14 +564,38 @@
 	}
 
 	/* old policy was in seconds, warn the user if too small */
-	if (standby < 60) {
+	if (timeout < 60) {
 		gpm_warning ("standby timeout is invalid, please re-configure");
 		return;
 	}
 
-	/* try to make up some reasonable numbers */
-	suspend = standby;
-	off     = standby * 2;
+	/* If we have no dpms_method, possible due to a schema problem */
+	if (dpms_method == NULL) {
+		dpms_method = "default";
+	}
+
+	/* Some monitors do not support certain suspend states, so we have to
+	 * provide a way to only use the one that works. */
+	if (strcmp (dpms_method, "standby") == 0) {
+		standby = timeout;
+		suspend = 0;
+		off     = 0;
+	} else if (strcmp (dpms_method, "suspend") == 0) {
+		standby = 0;
+		suspend = timeout;
+		off     = 0;
+	} else if (strcmp (dpms_method, "off") == 0) {
+		standby = 0;
+		suspend = 0;
+		off     = timeout;
+	} else {
+		/* suspend after one timeout, turn off after another */
+		standby = timeout;
+		suspend = timeout;
+		off     = timeout * 2;
+	}
+
+	gpm_debug ("DPMS parameters %d %d %d, method '%s'\n", standby, suspend, off, dpms_method);
 
 	error = NULL;
 	res = gpm_dpms_set_enabled (manager->priv->dpms, TRUE, &error);
@@ -2327,6 +2359,14 @@
 		sync_dpms_policy (manager);
 
 	} else if (strcmp (entry->key, GPM_PREF_AC_SLEEP_DISPLAY) == 0) {
+
+		sync_dpms_policy (manager);
+
+	} else if (strcmp (entry->key, GPM_PREF_AC_DPMS_METHOD) == 0) {
+
+		sync_dpms_policy (manager);
+
+	} else if (strcmp (entry->key, GPM_PREF_BATTERY_DPMS_METHOD) == 0) {
 
 		sync_dpms_policy (manager);
 
Index: src/gpm-prefs.h
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/src/gpm-prefs.h,v
retrieving revision 1.42
diff -u -u -r1.42 gpm-prefs.h
--- src/gpm-prefs.h	23 Jun 2006 17:18:27 -0000	1.42
+++ src/gpm-prefs.h	30 Jul 2006 12:48:28 -0000
@@ -29,9 +29,11 @@
 
 #define GPM_PREF_AC_SLEEP_COMPUTER	GPM_PREF_DIR "/ac_sleep_computer"
 #define GPM_PREF_AC_SLEEP_DISPLAY	GPM_PREF_DIR "/ac_sleep_display"
+#define GPM_PREF_AC_DPMS_METHOD		GPM_PREF_DIR "/ac_dpms_sleep_method"
 #define GPM_PREF_AC_BRIGHTNESS		GPM_PREF_DIR "/ac_brightness"
 #define GPM_PREF_BATTERY_SLEEP_COMPUTER	GPM_PREF_DIR "/battery_sleep_computer"
 #define GPM_PREF_BATTERY_SLEEP_DISPLAY	GPM_PREF_DIR "/battery_sleep_display"
+#define GPM_PREF_BATTERY_DPMS_METHOD	GPM_PREF_DIR "/battery_dpms_sleep_method"
 #define GPM_PREF_BATTERY_BRIGHTNESS	GPM_PREF_DIR "/battery_brightness"
 
 #define GPM_PREF_SLEEP_TYPE		GPM_PREF_DIR "/action_sleep_type"


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