How to enable the hibernation button?

I have the same problem as in I can hibernate with "systemctl" command, but not with User Indicator applet , I don’t want to have to type the password every time for sudo. I’m starting a new thread here because the solution doesn’t work for me and the file location might have changed since 2019.

I placed the com.ubuntu.enable-hibernate.pkla file once in
/etc/polkit-1/localauthority.conf.d/50-local.d/,
/etc/polkit-1/localauthority/50-local.d/ and
/var/lib/polkit-1/localauthority.conf.d/50-local.d/
rebooted each time, but the hibernation button is still disabled.
What am I missing?

1 Like

The old pkla file format is now deprecated in the latest versions of Ubuntu.

These files have been replaced by rules files,examples of which are in /etc/polkit-1/rules.d

So you need to translate from the pkla content format to the rules format

3 Likes

Thanks for the hint! I used the rules and it worked immediately! There were no examples but the code suggested by others did the trick.

Create a file:

nano /etc/polkit-1/rules.d/10-enable-hibernate.rules

Add the following lines:

polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.login1.hibernate" ||
        action.id == "org.freedesktop.login1.hibernate-multiple-sessions" ||
        action.id == "org.freedesktop.upower.hibernate" ||
        action.id == "org.freedesktop.login1.handle-hibernate-key" ||
        action.id == "org.freedesktop.login1.hibernate-ignore-inhibit")
    {
        return polkit.Result.YES;
    }
});

It even was effective without rebooting or restarting the session.

Sources: A and B

3 Likes