diff -crB 1.18.3/liblightdm-gobject/power.c 1.18.3-upower-fix/liblightdm-gobject/power.c *** 1.18.3/liblightdm-gobject/power.c 2017-01-10 14:31:57.887194653 +0000 --- 1.18.3-upower-fix/liblightdm-gobject/power.c 2017-01-11 00:39:37.704643002 +0000 *************** *** 8,13 **** --- 8,20 ---- * See http://www.gnu.org/copyleft/lgpl.html the full text of the license. */ + /* + * Modified 2017-01-11 + * Author: Fitzcarraldo + * + * Replaced UPower Suspend and Hibernate functionality with ConsoleKit. + */ + #include #include *************** *** 15,48 **** #include "lightdm/power.h" - static GDBusProxy *upower_proxy = NULL; static GDBusProxy *ck_proxy = NULL; static GDBusProxy *login1_proxy = NULL; static GVariant * ! upower_call_function (const gchar *function, GError **error) { ! if (!upower_proxy) { ! upower_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, ! G_DBUS_PROXY_FLAGS_NONE, ! NULL, ! "org.freedesktop.UPower", ! "/org/freedesktop/UPower", ! "org.freedesktop.UPower", ! NULL, ! error); ! if (!upower_proxy) ! return NULL; } ! return g_dbus_proxy_call_sync (upower_proxy, ! function, ! NULL, ! G_DBUS_CALL_FLAGS_NONE, ! -1, ! NULL, ! error); } static GVariant * --- 22,58 ---- #include "lightdm/power.h" static GDBusProxy *ck_proxy = NULL; static GDBusProxy *login1_proxy = NULL; static GVariant * ! ck_call_function (const gchar *function, GVariant *parameters, GError **error) { ! GVariant *r; ! ! if (!ck_proxy) { ! ck_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, ! G_DBUS_PROXY_FLAGS_NONE, ! NULL, ! "org.freedesktop.ConsoleKit", ! "/org/freedesktop/ConsoleKit/Manager", ! "org.freedesktop.ConsoleKit.Manager", ! NULL, ! error); ! if (!ck_proxy) ! return FALSE; } ! r = g_dbus_proxy_call_sync (ck_proxy, ! function, ! parameters, ! G_DBUS_CALL_FLAGS_NONE, ! -1, ! NULL, ! error); ! ! return r; } static GVariant * *************** *** 100,108 **** } else { ! r = upower_call_function ("SuspendAllowed", NULL); ! if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(b)"))) ! g_variant_get (r, "(b)", &can_suspend); } if (r) g_variant_unref (r); --- 110,120 ---- } else { ! r = ck_call_function ("CanSuspend", NULL, NULL); ! gchar *result; ! if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(s)"))) ! g_variant_get (r, "(&s)", &result); ! can_suspend = g_strcmp0 (result, "yes") == 0; } if (r) g_variant_unref (r); *************** *** 128,136 **** if (!result) { if (error) ! g_debug ("Can't suspend using logind; falling back to UPower: %s", (*error)->message); g_clear_error (error); ! result = upower_call_function ("Suspend", error); } suspended = result != NULL; --- 140,148 ---- if (!result) { if (error) ! g_debug ("Can't suspend using logind; falling back to ConsoleKit: %s", (*error)->message); g_clear_error (error); ! result = ck_call_function ("Suspend", g_variant_new("(b)", FALSE), error); } suspended = result != NULL; *************** *** 165,173 **** } else { ! r = upower_call_function ("HibernateAllowed", NULL); ! if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(b)"))) ! g_variant_get (r, "(b)", &can_hibernate); } if (r) g_variant_unref (r); --- 177,187 ---- } else { ! r = ck_call_function ("CanHibernate", NULL, NULL); ! gchar *result; ! if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(s)"))) ! g_variant_get (r, "(&s)", &result); ! can_hibernate = g_strcmp0 (result, "yes") == 0; } if (r) g_variant_unref (r); *************** *** 193,201 **** if (!result) { if (error) ! g_debug ("Can't hibernate using logind; falling back to UPower: %s", (*error)->message); g_clear_error (error); ! result = upower_call_function ("Hibernate", error); } hibernated = result != NULL; --- 207,215 ---- if (!result) { if (error) ! g_debug ("Can't hibernate using logind; falling back to ConsoleKit: %s", (*error)->message); g_clear_error (error); ! result = ck_call_function ("Hibernate", g_variant_new("(b)", FALSE), error); } hibernated = result != NULL; *************** *** 205,239 **** return hibernated; } - static GVariant * - ck_call_function (const gchar *function, GError **error) - { - GVariant *r; - - if (!ck_proxy) - { - ck_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - "org.freedesktop.ConsoleKit", - "/org/freedesktop/ConsoleKit/Manager", - "org.freedesktop.ConsoleKit.Manager", - NULL, - error); - if (!ck_proxy) - return FALSE; - } - - r = g_dbus_proxy_call_sync (ck_proxy, - function, - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - error); - - return r; - } /** * lightdm_get_can_restart: --- 219,224 ---- *************** *** 260,266 **** } else { ! r = ck_call_function ("CanRestart", NULL); if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(b)"))) g_variant_get (r, "(b)", &can_restart); } --- 245,251 ---- } else { ! r = ck_call_function ("CanRestart", NULL, NULL); if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(b)"))) g_variant_get (r, "(b)", &can_restart); } *************** *** 288,294 **** if (!r) { g_clear_error (error); ! r = ck_call_function ("Restart", error); } restarted = r != NULL; if (r) --- 273,279 ---- if (!r) { g_clear_error (error); ! r = ck_call_function ("Restart", NULL, error); } restarted = r != NULL; if (r) *************** *** 322,328 **** } else { ! r = ck_call_function ("CanStop", NULL); if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(b)"))) g_variant_get (r, "(b)", &can_shutdown); } --- 307,313 ---- } else { ! r = ck_call_function ("CanStop", NULL, NULL); if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(b)"))) g_variant_get (r, "(b)", &can_shutdown); } *************** *** 350,356 **** if (!r) { g_clear_error (error); ! r = ck_call_function ("Stop", error); } shutdown = r != NULL; if (r) --- 335,341 ---- if (!r) { g_clear_error (error); ! r = ck_call_function ("Stop", NULL, error); } shutdown = r != NULL; if (r)