File gnome-power-manager-schedule-wakeups.patch of Package gnome-power-manager

diff --git a/data/gpm-prefs.glade b/data/gpm-prefs.glade
index d3d9629..340e45b 100644
--- a/data/gpm-prefs.glade
+++ b/data/gpm-prefs.glade
@@ -1072,6 +1072,423 @@
                 <property name="tab_fill">False</property>
               </packing>
             </child>
+	  <child>
+	    <widget class="GtkVBox" id="vbox_scheduling">
+	      <property name="border_width">12</property>
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">6</property>
+
+	      <child>
+		<widget class="GtkVBox" id="vbox97">
+		  <property name="visible">True</property>
+		  <property name="homogeneous">False</property>
+		  <property name="spacing">6</property>
+
+		  <child>
+		    <widget class="GtkLabel" id="label127">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">&lt;b&gt;Automatic Wakeup&lt;/b&gt;</property>
+		      <property name="use_underline">False</property>
+		      <property name="use_markup">True</property>
+		      <property name="justify">GTK_JUSTIFY_LEFT</property>
+		      <property name="wrap">False</property>
+		      <property name="selectable">False</property>
+		      <property name="xalign">0</property>
+		      <property name="yalign">0.5</property>
+		      <property name="xpad">0</property>
+		      <property name="ypad">0</property>
+		      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		      <property name="width_chars">-1</property>
+		      <property name="single_line_mode">False</property>
+		      <property name="angle">0</property>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkAlignment" id="alignment52">
+		      <property name="visible">True</property>
+		      <property name="xalign">0.5</property>
+		      <property name="yalign">0.5</property>
+		      <property name="xscale">1</property>
+		      <property name="yscale">1</property>
+		      <property name="top_padding">0</property>
+		      <property name="bottom_padding">0</property>
+		      <property name="left_padding">12</property>
+		      <property name="right_padding">0</property>
+
+		      <child>
+			<widget class="GtkVBox" id="vbox98">
+			  <property name="visible">True</property>
+			  <property name="homogeneous">False</property>
+			  <property name="spacing">6</property>
+
+			  <child>
+			    <widget class="GtkCheckButton" id="checkbutton_scheduling_wakeup">
+			      <property name="visible">True</property>
+			      <property name="can_focus">True</property>
+			      <property name="label" translatable="yes">Automatically wake up from suspend or hibernate at a given time</property>
+			      <property name="use_underline">True</property>
+			      <property name="relief">GTK_RELIEF_NORMAL</property>
+			      <property name="focus_on_click">True</property>
+			      <property name="active">False</property>
+			      <property name="inconsistent">False</property>
+			      <property name="draw_indicator">True</property>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">False</property>
+			      <property name="fill">False</property>
+			    </packing>
+			  </child>
+
+			  <child>
+			    <widget class="GtkHBox" id="hbox22">
+			      <property name="visible">True</property>
+			      <property name="homogeneous">True</property>
+			      <property name="spacing">12</property>
+
+			      <child>
+				<widget class="GtkLabel" id="label_scheduling_wakeup_at">
+				  <property name="visible">True</property>
+				  <property name="label" translatable="yes">Wake up at:</property>
+				  <property name="use_underline">True</property>
+				  <property name="use_markup">False</property>
+				  <property name="justify">GTK_JUSTIFY_LEFT</property>
+				  <property name="wrap">False</property>
+				  <property name="selectable">False</property>
+				  <property name="xalign">0</property>
+				  <property name="yalign">0.5</property>
+				  <property name="xpad">0</property>
+				  <property name="ypad">0</property>
+				  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+				  <property name="width_chars">-1</property>
+				  <property name="single_line_mode">False</property>
+				  <property name="angle">0</property>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">True</property>
+				  <property name="fill">True</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkHBox" id="hbox24">
+				  <property name="visible">True</property>
+				  <property name="homogeneous">False</property>
+				  <property name="spacing">0</property>
+
+				  <child>
+				    <widget class="GtkSpinButton" id="spinbutton_scheduling_wakeup_hour">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="climb_rate">1</property>
+				      <property name="digits">0</property>
+				      <property name="numeric">True</property>
+				      <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+				      <property name="snap_to_ticks">False</property>
+				      <property name="wrap">True</property>
+				      <property name="adjustment">6 0 23 1 10 10</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkLabel" id="label131">
+				      <property name="visible">True</property>
+				      <property name="label" translatable="yes">:</property>
+				      <property name="use_underline">False</property>
+				      <property name="use_markup">False</property>
+				      <property name="justify">GTK_JUSTIFY_LEFT</property>
+				      <property name="wrap">False</property>
+				      <property name="selectable">False</property>
+				      <property name="xalign">0.5</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xpad">0</property>
+				      <property name="ypad">0</property>
+				      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+				      <property name="width_chars">-1</property>
+				      <property name="single_line_mode">False</property>
+				      <property name="angle">0</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkSpinButton" id="spinbutton_scheduling_wakeup_minute">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="climb_rate">1</property>
+				      <property name="digits">0</property>
+				      <property name="numeric">True</property>
+				      <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+				      <property name="snap_to_ticks">False</property>
+				      <property name="wrap">True</property>
+				      <property name="adjustment">0 0 59 1 10 10</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">True</property>
+				  <property name="fill">True</property>
+				</packing>
+			      </child>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">False</property>
+			      <property name="fill">False</property>
+			    </packing>
+			  </child>
+
+			  <child>
+			    <widget class="GtkHBox" id="hbox23">
+			      <property name="visible">True</property>
+			      <property name="homogeneous">True</property>
+			      <property name="spacing">12</property>
+
+			      <child>
+				<widget class="GtkLabel" id="label_scheduling_wakeup_on">
+				  <property name="visible">True</property>
+				  <property name="label" translatable="yes">Wake up on these days:</property>
+				  <property name="use_underline">True</property>
+				  <property name="use_markup">False</property>
+				  <property name="justify">GTK_JUSTIFY_LEFT</property>
+				  <property name="wrap">False</property>
+				  <property name="selectable">False</property>
+				  <property name="xalign">0</property>
+				  <property name="yalign">0</property>
+				  <property name="xpad">0</property>
+				  <property name="ypad">0</property>
+				  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+				  <property name="width_chars">-1</property>
+				  <property name="single_line_mode">False</property>
+				  <property name="angle">0</property>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">True</property>
+				  <property name="fill">True</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkVBox" id="vbox101">
+				  <property name="visible">True</property>
+				  <property name="homogeneous">False</property>
+				  <property name="spacing">0</property>
+
+				  <child>
+				    <widget class="GtkCheckButton" id="checkbutton_scheduling_wakeup_1">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="label" translatable="yes">Monday</property>
+				      <property name="use_underline">True</property>
+				      <property name="relief">GTK_RELIEF_NORMAL</property>
+				      <property name="focus_on_click">True</property>
+				      <property name="active">False</property>
+				      <property name="inconsistent">False</property>
+				      <property name="draw_indicator">True</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkCheckButton" id="checkbutton_scheduling_wakeup_2">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="label" translatable="yes">Tuesday</property>
+				      <property name="use_underline">True</property>
+				      <property name="relief">GTK_RELIEF_NORMAL</property>
+				      <property name="focus_on_click">True</property>
+				      <property name="active">False</property>
+				      <property name="inconsistent">False</property>
+				      <property name="draw_indicator">True</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkCheckButton" id="checkbutton_scheduling_wakeup_3">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="label" translatable="yes">Wednesday</property>
+				      <property name="use_underline">True</property>
+				      <property name="relief">GTK_RELIEF_NORMAL</property>
+				      <property name="focus_on_click">True</property>
+				      <property name="active">False</property>
+				      <property name="inconsistent">False</property>
+				      <property name="draw_indicator">True</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkCheckButton" id="checkbutton_scheduling_wakeup_4">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="label" translatable="yes">Thursday</property>
+				      <property name="use_underline">True</property>
+				      <property name="relief">GTK_RELIEF_NORMAL</property>
+				      <property name="focus_on_click">True</property>
+				      <property name="active">False</property>
+				      <property name="inconsistent">False</property>
+				      <property name="draw_indicator">True</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkCheckButton" id="checkbutton_scheduling_wakeup_5">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="label" translatable="yes">Friday</property>
+				      <property name="use_underline">True</property>
+				      <property name="relief">GTK_RELIEF_NORMAL</property>
+				      <property name="focus_on_click">True</property>
+				      <property name="active">False</property>
+				      <property name="inconsistent">False</property>
+				      <property name="draw_indicator">True</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkCheckButton" id="checkbutton_scheduling_wakeup_6">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="label" translatable="yes">Saturday</property>
+				      <property name="use_underline">True</property>
+				      <property name="relief">GTK_RELIEF_NORMAL</property>
+				      <property name="focus_on_click">True</property>
+				      <property name="active">False</property>
+				      <property name="inconsistent">False</property>
+				      <property name="draw_indicator">True</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkCheckButton" id="checkbutton_scheduling_wakeup_7">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="label" translatable="yes">Sunday</property>
+				      <property name="use_underline">True</property>
+				      <property name="relief">GTK_RELIEF_NORMAL</property>
+				      <property name="focus_on_click">True</property>
+				      <property name="active">False</property>
+				      <property name="inconsistent">False</property>
+				      <property name="draw_indicator">True</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">False</property>
+				  <property name="fill">True</property>
+				</packing>
+			      </child>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">False</property>
+			      <property name="fill">False</property>
+			    </packing>
+			  </child>
+			</widget>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">True</property>
+		      <property name="fill">True</property>
+		    </packing>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">True</property>
+		</packing>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="tab_expand">False</property>
+	      <property name="tab_fill">True</property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkLabel" id="label_tab_scheduling">
+	      <property name="visible">True</property>
+	      <property name="label" translatable="yes">Scheduling</property>
+	      <property name="use_underline">False</property>
+	      <property name="use_markup">False</property>
+	      <property name="justify">GTK_JUSTIFY_LEFT</property>
+	      <property name="wrap">False</property>
+	      <property name="selectable">False</property>
+	      <property name="xalign">0.5</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">0</property>
+	      <property name="ypad">0</property>
+	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+	      <property name="width_chars">-1</property>
+	      <property name="single_line_mode">False</property>
+	      <property name="angle">0</property>
+	    </widget>
+	    <packing>
+	      <property name="type">tab</property>
+	    </packing>
+	  </child>
           </widget>
           <packing>
             <property name="fill">False</property>
diff --git a/src/gpm-conf.h b/src/gpm-conf.h
index 66b3729..83d4b02 100644
--- a/src/gpm-conf.h
+++ b/src/gpm-conf.h
@@ -86,6 +86,18 @@ G_BEGIN_DECLS
 #define GPM_CONF_POLICY_TIMEOUT			GPM_CONF_DIR "/general/policy_suppression_timeout"
 #define GPM_CONF_IGNORE_INHIBITS		GPM_CONF_DIR "/general/ignore_inhibit_requests"
 
+/* scheduling */
+#define GPM_CONF_SCHEDULING_WAKEUP			GPM_CONF_DIR "/scheduling/wakeup"
+#define GPM_CONF_SCHEDULING_WAKEUP_HOUR			GPM_CONF_DIR "/scheduling/wakeup_hour"
+#define GPM_CONF_SCHEDULING_WAKEUP_MINUTE			GPM_CONF_DIR "/scheduling/wakeup_minute"
+#define GPM_CONF_SCHEDULING_WAKEUP_DAY1			GPM_CONF_DIR "/scheduling/wakeup_on_monday"
+#define GPM_CONF_SCHEDULING_WAKEUP_DAY2			GPM_CONF_DIR "/scheduling/wakeup_on_tuesday"
+#define GPM_CONF_SCHEDULING_WAKEUP_DAY3			GPM_CONF_DIR "/scheduling/wakeup_on_wednesday"
+#define GPM_CONF_SCHEDULING_WAKEUP_DAY4			GPM_CONF_DIR "/scheduling/wakeup_on_thursday"
+#define GPM_CONF_SCHEDULING_WAKEUP_DAY5			GPM_CONF_DIR "/scheduling/wakeup_on_friday"
+#define GPM_CONF_SCHEDULING_WAKEUP_DAY6			GPM_CONF_DIR "/scheduling/wakeup_on_saturday"
+#define GPM_CONF_SCHEDULING_WAKEUP_DAY7			GPM_CONF_DIR "/scheduling/wakeup_on_sunday"
+
 /* keyboard */
 #define GPM_CONF_KEYBOARD_BRIGHTNESS_AC		GPM_CONF_DIR "/keyboard/brightness_ac"
 #define GPM_CONF_KEYBOARD_BRIGHTNESS_BATT	GPM_CONF_DIR "/keyboard/brightness_battery"
diff --git a/src/gpm-control.c b/src/gpm-control.c
index f3577b6..45fbf3c 100644
--- a/src/gpm-control.c
+++ b/src/gpm-control.c
@@ -394,10 +394,84 @@ gpm_control_get_lock_policy (GpmControl  *control,
 	return do_lock;
 }
 
+/**
+ * gpm_control_get_wakeup:
+ * @control: This class instance
+ *
+ * This function calculates, based on the user's preferences, when we should
+ * wakeup from suspend.
+ *
+ * Return value: the number of seconds to sleep
+ **/
+guint
+gpm_control_get_wakeup (GpmConf  *conf)
+{
+	guint wakeup = 0;
+    gint seconds_from_now;
+	gboolean enable_wakeup;
+    gint hh, mm;
+	gboolean alarm_days[7];
+    time_t now_t;
+    time_t alarm_t;
+    struct tm * now_tm;
+    struct tm * alarm_tm;
+    guint i = 0;
+
+	gpm_conf_get_bool (conf, GPM_CONF_SCHEDULING_WAKEUP, &enable_wakeup);
+	if (!enable_wakeup) {
+        return 0;
+    }
+
+    gpm_conf_get_int (conf, GPM_CONF_SCHEDULING_WAKEUP_HOUR, &hh);
+    gpm_conf_get_int (conf, GPM_CONF_SCHEDULING_WAKEUP_MINUTE, &mm);
+
+    // Put Sunday first in the array to interface w/ struct tm.tm_wday
+    gpm_conf_get_bool (conf, GPM_CONF_SCHEDULING_WAKEUP_DAY7, &alarm_days[0]);
+    gpm_conf_get_bool (conf, GPM_CONF_SCHEDULING_WAKEUP_DAY1, &alarm_days[1]);
+    gpm_conf_get_bool (conf, GPM_CONF_SCHEDULING_WAKEUP_DAY2, &alarm_days[2]);
+    gpm_conf_get_bool (conf, GPM_CONF_SCHEDULING_WAKEUP_DAY3, &alarm_days[3]);
+    gpm_conf_get_bool (conf, GPM_CONF_SCHEDULING_WAKEUP_DAY4, &alarm_days[4]);
+    gpm_conf_get_bool (conf, GPM_CONF_SCHEDULING_WAKEUP_DAY5, &alarm_days[5]);
+    gpm_conf_get_bool (conf, GPM_CONF_SCHEDULING_WAKEUP_DAY6, &alarm_days[6]);
+
+    time (&now_t);
+    now_tm = localtime (&now_t);
+    alarm_tm = localtime (&now_t);
+
+    // The first alarm time to try is today at the given hour/minute
+    alarm_tm->tm_hour = hh;
+    alarm_tm->tm_min = mm;
+    alarm_tm->tm_sec = 0; 
+    alarm_t = mktime (alarm_tm);
+
+    // The next alarm has to be at most 7 days from now
+    for (i = 0; i < 8; i++) {
+        alarm_tm = localtime (&alarm_t);
+
+        // Check that this day is an alarm-enabled day of the week
+        if (alarm_days[alarm_tm->tm_wday]) {
+            // Ensure the alarm time is more than 15 minutes from now
+            //   - otherwise we set the alarm for the next slot
+            // 900 seconds = 15 minutes * 60 seconds/minute
+            seconds_from_now = alarm_t - now_t;
+            if (seconds_from_now > 900) {
+                wakeup = (guint)seconds_from_now;
+                break;
+            }
+        }
+
+        // Add a day to try the date after
+        alarm_t += 3600 * 24;
+    }
+
+	return wakeup;
+}
+
 gboolean
 gpm_control_suspend (GpmControl *control,
 		     GError    **error)
 {
+    guint wakeup;
 	gboolean allowed;
 	gboolean ret;
 	gboolean do_lock;
@@ -438,11 +512,15 @@ gpm_control_suspend (GpmControl *control,
 		gpm_networkmanager_sleep ();
 	}
 
+	/* calculate when to wakeup */
+	wakeup = gpm_control_get_wakeup (control->priv->conf);
+	//printf ("going to wake up in %i seconds\n", wakeup);
+ 
 	/* Do the suspend */
 	egg_debug ("emitting sleep");
 	g_signal_emit (control, signals [SLEEP], 0, GPM_CONTROL_ACTION_SUSPEND);
 
-	ret = hal_gpower_suspend (control->priv->hal_power, 0, error);
+	ret = hal_gpower_suspend (control->priv->hal_power, wakeup, error);
 	if (!ret) {
 		gpm_control_convert_hal_error (control, error);
 	}
diff --git a/src/gpm-prefs-core.c b/src/gpm-prefs-core.c
index 9422ea4..25d3dfb 100644
--- a/src/gpm-prefs-core.c
+++ b/src/gpm-prefs-core.c
@@ -390,6 +390,79 @@ gpm_prefs_brightness_slider_changed_cb (GtkRange *range,
 }
 
 /**
+ * gpm_prefs_spinbutton_changed_cb:
+ * @spinbutton: The GtkSpinButton object
+ * @gpm_pref_key: The GConf key for this preference setting.
+ **/
+static void
+gpm_prefs_spinbutton_changed_cb (GtkSpinButton *spinbutton,
+					GpmPrefs *prefs)
+{
+	gint value;
+	gchar *gpm_pref_key;
+
+    value = gtk_spin_button_get_value_as_int (spinbutton);
+	gpm_pref_key = (char *) g_object_get_data (G_OBJECT (spinbutton), "conf_key");
+
+	g_object_set_data (G_OBJECT (spinbutton), "conf_key", (gpointer) gpm_pref_key);
+	egg_debug ("Changing %s to %i", gpm_pref_key, (int) value);
+	gpm_conf_set_int (prefs->priv->conf, gpm_pref_key, (gint) value);
+}
+
+/**
+ * gpm_prefs_spinbutton_output_cb:
+ * @spinbutton: The GtkSpinButton object
+ * @gpm_pref_key: The GConf key for this preference setting.
+ **/
+static void
+gpm_prefs_spinbutton_output_cb (GtkSpinButton *spinbutton,
+					GpmPrefs *prefs)
+{
+	gint value;
+    gchar* text = NULL;
+
+    value = gtk_spin_button_get_value_as_int (spinbutton);
+    text = g_strdup_printf ("%02i", value);
+    gtk_entry_set_text (GTK_ENTRY(spinbutton), text);
+
+    g_free (text);
+}
+
+
+/**
+ * gpm_prefs_setup_spinbutton:
+ * @prefs: This prefs class instance
+ * @widget_name: The GtkWidget name
+ * @gpm_pref_key: The GConf key for this preference setting.
+ **/
+static GtkWidget *
+gpm_prefs_setup_spinbutton (GpmPrefs    *prefs,
+			      const gchar *widget_name,
+			      const gchar *gpm_pref_key)
+{
+	GtkWidget *widget;
+	gint value;
+	gboolean is_writable;
+
+	widget = glade_xml_get_widget (prefs->priv->glade_xml, widget_name);
+
+	gpm_conf_get_int (prefs->priv->conf, gpm_pref_key, &value);
+	gpm_conf_is_writable (prefs->priv->conf, gpm_pref_key, &is_writable);
+
+	gtk_widget_set_sensitive (widget, is_writable);
+	gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), (gdouble)value);
+
+	g_object_set_data (G_OBJECT (widget), "conf_key", (gpointer) gpm_pref_key);
+
+	g_signal_connect (G_OBJECT (widget), "value-changed",
+			  G_CALLBACK (gpm_prefs_spinbutton_changed_cb), prefs);
+	g_signal_connect (G_OBJECT (widget), "output",
+			  G_CALLBACK (gpm_prefs_spinbutton_output_cb), prefs);
+
+	return widget;
+}
+
+/**
  * gpm_prefs_setup_brightness_slider:
  * @prefs: This prefs class instance
  * @widget_name: The GtkWidget name
@@ -542,6 +615,35 @@ gpm_prefs_setup_action_combo (GpmPrefs     *prefs,
 }
 
 /**
+ * gpm_prefs_wakeup_changed_cb
+ * @widget: The GtkWidget object
+ * @prefs: the GpmPrefs
+ **/
+static void
+gpm_prefs_wakeup_changed_cb (GtkWidget *widget,
+			    GpmPrefs  *prefs)
+{
+	gboolean checked;
+    GtkWidget * dep_widget;
+    gint i;
+    gchar * dep_widgets[] = {
+        "label_scheduling_wakeup_at", "label_scheduling_wakeup_on",
+        "spinbutton_scheduling_wakeup_hour", "spinbutton_scheduling_wakeup_minute",
+        "checkbutton_scheduling_wakeup_1", "checkbutton_scheduling_wakeup_2",
+        "checkbutton_scheduling_wakeup_3", "checkbutton_scheduling_wakeup_4",
+        "checkbutton_scheduling_wakeup_5", "checkbutton_scheduling_wakeup_6",
+        "checkbutton_scheduling_wakeup_7",
+    };
+
+	checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+
+    for (i = 0; i < 11; i++) {
+        dep_widget = glade_xml_get_widget (prefs->priv->glade_xml, dep_widgets[i]);
+        gtk_widget_set_sensitive (dep_widget, checked);
+    }
+}
+
+/**
  * gpm_prefs_checkbox_lock_cb:
  * @widget: The GtkWidget object
  * @gpm_pref_key: The GConf key for this preference setting.
@@ -896,6 +998,38 @@ prefs_setup_battery (GpmPrefs *prefs)
 }
 
 static void
+prefs_setup_scheduling (GpmPrefs *prefs)
+{
+	GtkWidget * enabled;
+
+    enabled = gpm_prefs_setup_checkbox (prefs, "checkbutton_scheduling_wakeup",
+				  GPM_CONF_SCHEDULING_WAKEUP);
+
+	gpm_prefs_setup_spinbutton (prefs, "spinbutton_scheduling_wakeup_hour",
+				  GPM_CONF_SCHEDULING_WAKEUP_HOUR);
+	gpm_prefs_setup_spinbutton (prefs, "spinbutton_scheduling_wakeup_minute",
+				  GPM_CONF_SCHEDULING_WAKEUP_MINUTE);
+
+	gpm_prefs_setup_checkbox (prefs, "checkbutton_scheduling_wakeup_1",
+				  GPM_CONF_SCHEDULING_WAKEUP_DAY1);
+	gpm_prefs_setup_checkbox (prefs, "checkbutton_scheduling_wakeup_2",
+				  GPM_CONF_SCHEDULING_WAKEUP_DAY2);
+	gpm_prefs_setup_checkbox (prefs, "checkbutton_scheduling_wakeup_3",
+				  GPM_CONF_SCHEDULING_WAKEUP_DAY3);
+	gpm_prefs_setup_checkbox (prefs, "checkbutton_scheduling_wakeup_4",
+				  GPM_CONF_SCHEDULING_WAKEUP_DAY4);
+	gpm_prefs_setup_checkbox (prefs, "checkbutton_scheduling_wakeup_5",
+				  GPM_CONF_SCHEDULING_WAKEUP_DAY5);
+	gpm_prefs_setup_checkbox (prefs, "checkbutton_scheduling_wakeup_6",
+				  GPM_CONF_SCHEDULING_WAKEUP_DAY6);
+	gpm_prefs_setup_checkbox (prefs, "checkbutton_scheduling_wakeup_7",
+				  GPM_CONF_SCHEDULING_WAKEUP_DAY7);
+
+	g_signal_connect (enabled, "clicked", G_CALLBACK (gpm_prefs_wakeup_changed_cb), prefs);
+	gpm_prefs_wakeup_changed_cb (enabled, prefs);
+}
+
+static void
 prefs_setup_ups (GpmPrefs *prefs)
 {
 	GtkWidget *widget;
@@ -1127,6 +1261,7 @@ gpm_prefs_init (GpmPrefs *prefs)
 
 	prefs_setup_ac (prefs);
 	prefs_setup_battery (prefs);
+	prefs_setup_scheduling (prefs);
 	prefs_setup_ups (prefs);
 	prefs_setup_general (prefs);
 	prefs_setup_notification (prefs);