From aa1636e8c74e74c878133c128518bf0640840118 Mon Sep 17 00:00:00 2001 From: Chris Ball Date: Tue, 17 Jul 2007 19:21:18 -0400 Subject: [PATCH] Replace the HAL Suspend call with a simple echo mem > /sys/power/state. This is because HAL's suspend does a VT switch and a bunch of unnecessary stuff for us. We should ask upstream HAL for a bare-bones suspend. --- plugins/policy/suspend/ohm-plugin-suspend.c | 39 ++++++++------------------ 1 files changed, 12 insertions(+), 27 deletions(-) diff --git a/plugins/policy/suspend/ohm-plugin-suspend.c b/plugins/policy/suspend/ohm-plugin-suspend.c index 1e08298..59c7c7f 100644 --- a/plugins/policy/suspend/ohm-plugin-suspend.c +++ b/plugins/policy/suspend/ohm-plugin-suspend.c @@ -38,33 +38,18 @@ enum { static gboolean system_suspend (OhmPlugin *plugin) { - DBusGConnection *connection; - DBusGProxy *proxy; - GError *error; - gboolean ret; - gint retval; - - connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL); - - /* reuse the connection from HAL */ - proxy = dbus_g_proxy_new_for_name (connection, - HAL_DBUS_SERVICE, - HAL_ROOT_COMPUTER, - HAL_DBUS_INTERFACE_POWER); - - /* get the brightness from HAL */ - error = NULL; - ret = dbus_g_proxy_call (proxy, "Suspend", &error, - G_TYPE_INT, 0, - G_TYPE_INVALID, - G_TYPE_UINT, &retval, - G_TYPE_INVALID); - if (error != NULL) { - g_printerr ("Error: %s\n", error->message); - g_error_free (error); - } - g_object_unref (proxy); - return ret; + FILE *fp; + + fp = g_fopen("/sys/power/state", "w"); + if (!fp) + g_warning ("Couldn't open /sys/power/state."); + + if (g_fprintf(fp, "mem\n") < 0) + g_warning ("Couldn't write to /sys/power/state."); + + fclose(fp); + + return TRUE; } /** -- 1.5.0.6