Re: [gpm] cpu idle / hot corners



On Sat, 2006-02-18 at 17:57 +0000, Richard Hughes wrote:
> On Sat, 2006-02-18 at 12:45 -0500, David Zeuthen wrote:
> > On Sat, 2006-02-18 at 18:20 +0100, Jaap A. Haitsma wrote:
> > > I like the idea of hot corners. Since according to fitts law the corners 
> > > should contain also contain stuff like the show desktop button I think 
> > > there needs to be some delay.
> > > 
> > > I guess we need to make a hot corners capplet and integrate the 
> > > functionality into gnome-settings daemon. IMHO it would be a great 
> > > addition for GNOME 2.16.
> > 
> > Agreed... this would be handy for power users indeed. 
> > 
> > Until then, can we please rip out the current "do not suspend when cpu
> > is not idle" code? It's just very confusing I think.
> 
> I'll make it a gconf configurable, default off -- then I can hack on the
> code and allow people to experiment.

Something like the attached I guess.

Richard.
Index: data/gnome-power-manager.schemas.in
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/data/gnome-power-manager.schemas.in,v
retrieving revision 1.10
diff -u -r1.10 gnome-power-manager.schemas.in
--- data/gnome-power-manager.schemas.in	18 Feb 2006 16:40:58 -0000	1.10
+++ data/gnome-power-manager.schemas.in	18 Feb 2006 20:17:37 -0000
@@ -2,6 +2,18 @@
   <schemalist>
 
     <schema>
+      <key>/schemas/apps/gnome-power-manager/check_type_cpu</key>
+      <applyto>/apps/gnome-power-manager/check_type_cpu</applyto>
+      <owner>gnome-power-manager</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+        <short>Check CPU load before sleeping</short>
+        <long>If we should check the CPU load before doing a suspend or hibernate.</long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/gnome-power-manager/dim_on_idle</key>
       <applyto>/apps/gnome-power-manager/dim_on_idle</applyto>
       <owner>gnome-power-manager</owner>
Index: src/gpm-idle.c
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/src/gpm-idle.c,v
retrieving revision 1.26
diff -u -r1.26 gpm-idle.c
--- src/gpm-idle.c	11 Feb 2006 19:29:10 -0000	1.26
+++ src/gpm-idle.c	18 Feb 2006 20:17:38 -0000
@@ -78,6 +78,8 @@
 	guint		 system_timer_id;
 	guint		 system_idle_timer_id;
 
+	gboolean	 check_type_cpu;
+
 	gboolean	 init;
 	cpudata		 cpu_old;
 };
@@ -105,19 +107,26 @@
 static gboolean
 poll_system_timer (GpmIdle *idle)
 {
-	gdouble load;
+	gdouble  load;
+	gboolean do_action = TRUE;
 
 	/* get our computed load value */
-	load = cpu_update_data (idle);
+	if (idle->priv->check_type_cpu) {
 
-	/* check if system is "idle" enough */
+		load = cpu_update_data (idle);
 
-	/* FIXME: should this stay below this level for a certain time? */
-	/* FIXME: check that we are on console? */
+		/* FIXME: should this stay below this level for a certain time? */
+		/* FIXME: check that we are on console? */
 
-	if (load < IDLE_LIMIT) {
-		gpm_debug ("Detected that the CPU is quiet");
+		if (load > IDLE_LIMIT) {
+			/* check if system is "idle" enough */
+			gpm_debug ("Detected that the CPU is busy");
+			do_action = FALSE;
+		}
+		
+	}
 
+	if (do_action) {
 		gpm_idle_set_mode (idle, GPM_IDLE_MODE_SYSTEM);
 
 		idle->priv->system_idle_timer_id = 0;
@@ -186,6 +195,17 @@
 	} else {
 		gpm_debug ("System idle disabled");
 	}
+}
+
+void
+gpm_idle_set_check_cpu (GpmIdle    *idle,
+			gboolean    check_type_cpu)
+{
+	g_return_if_fail (GPM_IS_IDLE (idle));
+
+	gpm_debug ("Setting the CPU load check to %i", check_type_cpu);
+
+	idle->priv->check_type_cpu = check_type_cpu;
 }
 
 void
Index: src/gpm-idle.h
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/src/gpm-idle.h,v
retrieving revision 1.7
diff -u -r1.7 gpm-idle.h
--- src/gpm-idle.h	6 Feb 2006 18:08:18 -0000	1.7
+++ src/gpm-idle.h	18 Feb 2006 20:17:38 -0000
@@ -63,6 +63,8 @@
 GpmIdleMode gpm_idle_get_mode            (GpmIdle    *idle);
 void        gpm_idle_set_mode            (GpmIdle    *idle,
                                           GpmIdleMode mode);
+void	    gpm_idle_set_check_cpu	 (GpmIdle    *idle,
+					  gboolean    check_type_cpu);
 
 void        gpm_idle_set_session_timeout (GpmIdle    *idle,
                                           guint       timeout);
Index: src/gpm-manager.c
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/src/gpm-manager.c,v
retrieving revision 1.59
diff -u -r1.59 gpm-manager.c
--- src/gpm-manager.c	18 Feb 2006 16:40:58 -0000	1.59
+++ src/gpm-manager.c	18 Feb 2006 20:17:40 -0000
@@ -1400,6 +1400,7 @@
 gpm_manager_init (GpmManager *manager)
 {
 	gboolean on_ac;
+	gboolean check_type_cpu;
 #if ACTIONS_MENU_ENABLED
 	gboolean enabled;
 #endif
@@ -1436,6 +1437,12 @@
 	manager->priv->idle = gpm_idle_new ();
 	g_signal_connect (manager->priv->idle, "changed",
 			  G_CALLBACK (idle_changed_cb), manager);
+
+	/* set up the check_type_cpu, so we can disable the CPU load check */
+	check_type_cpu = gconf_client_get_bool (manager->priv->gconf_client,
+						GPM_PREF_IDLE_CHECK_CPU,
+						NULL);
+	gpm_idle_set_check_cpu (manager->priv->idle, check_type_cpu);
 
 	manager->priv->dpms = gpm_dpms_new ();
 
Index: src/gpm-prefs.h
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/src/gpm-prefs.h,v
retrieving revision 1.20
diff -u -r1.20 gpm-prefs.h
--- src/gpm-prefs.h	18 Feb 2006 16:40:58 -0000	1.20
+++ src/gpm-prefs.h	18 Feb 2006 20:17:40 -0000
@@ -52,6 +52,8 @@
 #define GPM_PREF_LOCK_BUTTON_SUSPEND	GPM_PREF_DIR "/lock_button_suspend"
 #define GPM_PREF_LOCK_SLEEP_IDLE	GPM_PREF_DIR "/lock_sleep_idle"
 
+#define GPM_PREF_IDLE_CHECK_CPU		GPM_PREF_DIR "/check_type_cpu"
+
 typedef enum {
 	GPM_ICON_POLICY_ALWAYS,
 	GPM_ICON_POLICY_CHARGE,


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