Re: [gpm] suspend instead of hibernate when on ac-power



On Tue, 2007-03-20 at 13:52 +0100, Francesco Fumanti wrote:
> Hello,
> It happens on a 2.8GHz celeron D desktop computer.
> 
> Since Feisty, the popup menu to select sleep type has disappeared, so I
> used the Configuration Editor to set sleep type.

Sure, it was removed from the UI as we can make some good guesses about
what the user wants.

> Consequently, I have set the ac_action_sleep_type to hibernate. But the
> computer still does a suspend when idle.

The code that decides what to do is here:

/**
 * idle_do_sleep:
 * @manager: This class instance
 *
 * This callback is called when we want to sleep. Use the users
 * preference from gconf, but change it if we can't do the action.
 **/
static void
idle_do_sleep (GpmManager *manager)
{
	GpmAcAdapterState state;
	gchar *action = NULL;
	gboolean ret;

	/* find if we are on AC power */
	gpm_ac_adapter_get_state (manager->priv->ac_adapter, &state);

	if (state == GPM_AC_ADAPTER_PRESENT) {
		gpm_conf_get_string (manager->priv->conf, GPM_CONF_AC_SLEEP_TYPE, &action);
	} else {
		gpm_conf_get_string (manager->priv->conf, GPM_CONF_BATTERY_SLEEP_TYPE, &action);
	}

	if (action == NULL) {
		gpm_warning ("action NULL, gconf error");
		return;
	}

	if (strcmp (action, ACTION_NOTHING) == 0) {
		gpm_debug ("doing nothing as system idle action");

	} else if (strcmp (action, ACTION_SUSPEND) == 0) {
		gpm_info_explain_reason (manager->priv->info, GPM_EVENT_SUSPEND,
					_("Suspending computer"), _("System idle"));
		ret = gpm_control_suspend (manager->priv->control, NULL);
		if (ret == FALSE) {
			gpm_warning ("cannot suspend, so trying hibernate");
			ret = gpm_control_hibernate (manager->priv->control, NULL);
			if (ret == FALSE) {
				gpm_warning ("cannot suspend or hibernate!");
			}
		}

	} else if (strcmp (action, ACTION_HIBERNATE) == 0) {
		gpm_info_explain_reason (manager->priv->info, GPM_EVENT_HIBERNATE,
					_("Hibernating computer"), _("System idle"));
		ret = gpm_control_hibernate (manager->priv->control, NULL);
		if (ret == FALSE) {
			gpm_warning ("cannot hibernate, so trying suspend");
			ret = gpm_control_suspend (manager->priv->control, NULL);
			if (ret == FALSE) {
				gpm_warning ("cannot suspend or hibernate!");
			}
		}
	}
	g_free (action);
}

I'm guessing the policy is set to hibernate, but that fails for some
reason, so g-p-m tries to suspend instead. Does this make things
clearer? If you can attach the output of gnome-power-manager when the
hibernate is attempted, we can debug this further.

Hope this helps,

Richard.





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