Yep, I'd forgotten about suspend/hibernate support being dropped by upower and moved to systemd-logind back in 2014:
https://gentoo.org/support/news-items/2 ... stemd.html
Gentoo News wrote:Title: UPower loses hibernate / suspend to systemd
Author: Samuli Suominen <
ssuominen@gentoo.org>
Content-Type: text/plain
Posted: 2014-06-03
Revision: 1
News-Item-Format: 1.0
Display-If-Installed: <sys-power/upower-0.99.0
UPower discontinued hibernate and suspend support in favor of systemd.
Because of this, we have created a compability package at
sys-power/upower-pm-utils which will give you the old UPower with
sys-power/pm-utils support back.
Some desktops have integrated the sys-power/pm-utils support directly
to their code, like Xfce, and as a result, they work also with the new
UPower as expected.
All non-systemd users are recommended to choose between:
# emerge --oneshot --noreplace 'sys-power/upower-pm-utils'
or
# emerge --oneshot --noreplace '>=sys-power/upower-0.99.0'
However, all systemd users are recommended to stay with sys-power/upower.
A small tip for GNOME _and_ systemd users, only 3.12 and newer support 0.99,
so if you see the package manager pulling in sys-power/upower-pm-utils
while using old GNOME, like 2.32 or 3.10, you _can_ prevent it by adding
a package.mask entry for >=sys-power/upower-0.99
Looking at the
lightdm-1.18.3 source code, I see in liblightdm-gobject/power.c that, indeed, LightDM uses org.freedesktop.login1 (systemd-logind) to Suspend and Hibernate, with org.freedesktop.UPower as the fallback if systemd-logind is not working. And, as we know, upower =>0.99 no longer supports suspension and hibernation.
These days the advice in the Gentoo News item of 2014-06-03 has been superseded: We are now told that upower-pm-utils is no longer needed (
Gentoo Bug Report No. 596988 - [TRACKER] sys-power/upower-pm-utils removal request) and we should unmerge it, merge upower, and merge consolekit with USE="pm-utils". This is because the version of ConsoleKit used by Gentoo supports Suspend/Hibernate. Even so, the LightDM code as it stands still uses only org.freedesktop.login1 and org.freedesktop.UPower, and so it still does not allow suspension and hibernation in Gentoo without systemd. So I attempted to modify power.c in lightdm-1.18.3 to use org.freedesktop.ConsoleKit for Suspend/Resume instead of org.freedesktop.UPower. I'm not sure I have done it correctly, but here's my patch anyway:
Code: Select all
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 <fitzcarralo1@hotmail.com>
+ *
+ * Replaced UPower Suspend and Hibernate functionality with ConsoleKit.
+ */
+
#include <config.h>
#include <string.h>
***************
*** 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)
However, I subsequently discovered that the LightDM KDE Greeter (x11-misc/lightdm-kde-0.3.2.1-r1) also still assumes UPower provides Suspend and Hibernate:
https://cgit.kde.org/lightdm.git/
So the Greeter is broken too. Arghhh!
Anyway, I've wasted too much time on this already and I'm not going to waste more time trying to modify the KDE Greeter's code. Therefore, to stop it annoying me, I have removed the greyed-out Suspend button from the Greeter's login screen by changing the following entry in /usr/share/apps/lightdm-kde-greeter/themes/classic/main.qml from:
Code: Select all
PlasmaWidgets.IconWidget {
text: i18n("Suspend")
icon: QIcon("system-suspend")
enabled: power.canSuspend;
onClicked: {power.suspend();
}
to:
Code: Select all
PlasmaWidgets.IconWidget {
text: i18n("Suspend")
icon: QIcon("system-suspend")
visible: power.canSuspend;
onClicked: {power.suspend();
}
By the way, the reason the KDE Greeter doesn't display a Hibernate button is because it is hidden by default in /usr/share/apps/lightdm-kde-greeter/themes/classic/main.qml:
Code: Select all
PlasmaWidgets.IconWidget {
text: i18n("Hibernate")
icon: QIcon("system-suspend-hibernate")
//Hibernate is a special case, lots of distros disable it, so if it's not enabled don't show it
visible: power.canHibernate;
onClicked: {power.hibernate();
}
Why oh why did freedesktop.org have to move the Suspend and Hibernate functionality out of UPower into systemd-logind. As a result it's a major PITA to try to get some applications to work properly if you don't use systemd.
