0

Now that I managed to extend swap and enable hibernation, I'd like hibernate to be available from the menu and as an action under the power button.

I tried assigning hibernate through gsettings

$ gsettings set org.gnome.settings-daemon.plugins.power power-button-action hibernate

but it only brings up an interactive shutdown menu instead.

I have also tried looking for a GNOME extension to make hibernate visible in the menu. However, the only extension compatible with my GNOME (42.2) is Hibernate Status Button by p91paul which doesn't seem to have any effect.

How to enable hibernation with the power button and in the GNOME menu on Ubuntu 22.04?

I can successfully hibernate issuing

sudo systemctl hibernate

so the mechanism is working. I only need the UI options.

2 Answers2

1

OK, I have the first half of the solution. It is possible to surface hibernate in the menu.

The extension is fine but requires additional steps:

NOTE: Pop!OS and Ubuntu require a file at /etc/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla

To create this file, run:

sudo nano /etc/polkit-1/localauthority/10-vendor.d/com.ubuntu.pkla

Then copy these contents into the newly created file:

[Enable hibernate in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

[Enable hibernate in logind] Identity=unix-user:* Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit ResultActive=yes

The question of how to make the power button hibernate remains.

  • With your solution Dawn Terminal, all you then have to do is go to Gnome Settings->Power and select Hibernate from the Power Button Behaviour drop-down. Nice One :-D – RAS Nov 13 '22 at 02:41
1

I have two solutions, I tried both of them, always at least one of them is working.

Solution 1

You can use Hibernate Status Button by p91paul. But you need a requirement, just install polkitd-pkla by running

sudo apt install polkitd-pkla

on terminal. (I found from comments)

Solution 2

As mentioned as on extension's GitHub page:

Hibernation button does not show up, but systemctl hibernate works

If you are running Ubuntu, try putting

[Enable hibernate in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

[Enable hibernate in logind] Identity=unix-user:* Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle->hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate->multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit ResultActive=yes

into /etc/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla

So you can try this method. Open a terminal and run

sudo nano /etc/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla

and copy-paste this:

[Enable hibernate in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

[Enable hibernate in logind] Identity=unix-user:* Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit ResultActive=yes

0x01010
  • 111