5

I'd like to be able to suspend-then-hibernate automatically with xfce4-power-manager, though I'm not sure if this is possible.

I believe this is a permission error with polkit1 because:

$ xfce4-power-manager --dump
---------------------------------------------------
       Xfce power manager version 1.6.1
With policykit support
With network manager support
---------------------------------------------------
Can suspend: True
Can hibernate: False
Authorized to suspend: True
Authorized to hibernate: False
Authorized to shutdown: True
Has battery: True
Has brightness panel: True
Has power button: True
Has hibernate button: True
Has sleep button: True
Has LID: True

My polkitsettings under/usr/share/polkit-1/actions/org.freedesktop.login1.policyare identical for suspend and hibernate, so it doesn't make much sense whenxfce-power-manager` can't access hibernate options.

According to How to go automatically from Suspend into Hibernate?: I've created /etc/systemd/sleep.conf and tested it. The following command does work (suspend and then hibernates according to sleep.conf):

sudo systemctl suspend-then-hibernate

But this does not work when I use xfce4-power-manager to do the suspension.

A post I found (How to go automatically from Suspend into Hibernate?) is similar, but is not exactly what I'm trying to do. I don't care about lid closed operation, I want everything time related.

cts
  • 51

2 Answers2

6

I had a similar problem, and found your question before I stumbled on the answer:

xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/logind-handle-lid-switch -n -t bool -s true

This page is where I found the answer:

https://docs.xfce.org/xfce/xfce4-power-manager/faq

If you want everything time related, then you can set them with settings in systemd and logind.conf

Here's a place to start:

https://wiki.archlinux.org/index.php/systemd#Power_management

I hope this helps you!

Chris
  • 61
  • 2
2

The answer from Chris did not help me. But at least directed me to something about polkit.

So, I went to /usr/share/polkit-1 and did a recursive grep for polkit, trying to find something relevant. And I found!

At file /usr/share/polkit-1/rules.d/com.ubuntu.desktop.rules (may be different for your distro), there's this sequence:

// Disable hibernate by default in Ubuntu
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.upower.hibernate" ||
         action.id == "org.freedesktop.login1.hibernate" ||
         action.id == "org.freedesktop.login1.handle-hibernate-key" ||
         action.id == "org.freedesktop.login1.hibernate-multiple-sessions") {
            return polkit.Result.NO;
    }
});

All I did was changing the NO for a YES. It still did not work at first but then I restarted polkit:

systemctl restart polkit

And restarted XFCE Panel Action Buttons. This was not obvious. I 've done it by removing and readding to the panel. Note that after readding the options will be reset (don't know why) and you have to enable hibernate button again, in its properties.

Jonny
  • 141