23

GNOME Shell doesn't have an option to hibernate in the session menu. I checked the GNOME Shell Cheat Sheet but hibernate is not mentioned there.

How can I hibernate my machine from within a GNOME Shell session?

pomsky
  • 68,507
dv3500ea
  • 37,204

11 Answers11

11

Just install this GNOME Shell extension by sliding the slider. Your user menu should now show a few new extra options: Hibernate, and Power Off...

enter image description here

10

dv3500ea In your link to GNOME Shell Cheat Sheet you got the answer:

The Power Off... menu entry is hidden by default. You can make it visible by pressing the Alt key in the user menu.

Just hold ALT

oren
  • 109
7
sudo apt-get install pm-utils

Alt+F2

sudo pm-hibernate
5

I don't think it is possible to manually hibernate in GNOME Shell (I could be wrong). There is an extension that adds extra options for power management, but having not had sucess installing extensions myself, I cannot tell you for sure how to install it.

For now, you can hit alt + f2 and type pmi action hibernate or gnome-power-cmd hibernate (10.10 and lower only), then press enter. This will not give you any options, so only do this if you are sure you won't want to cancel.

If you want to make this easier, you could create a script with (using zenity to provide options) and place this in ~/bin. You could then create a keyboard binding for the script, so when you press (for example) alt+super+h your system would hibernate.

RolandiXor
  • 51,541
  • I guess gnome-power-cmd is no longer available in 11.04, Refer:https://answers.launchpad.net/ubuntu/+source/gnome-power-manager/+question/85949; alternative is : gshutdown http://gshutdown.tuxfamily.org/en/index.php. – user7044 Sep 13 '11 at 07:47
  • To use the pmi command I had to install the powermanagement-interface package. Unfortunately I get an error when I use it: Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Hal was not provided by any .service files. – dv3500ea Sep 13 '11 at 20:56
  • @dv3500ea aw man... I'll have to find the correct command for GNOME 3 again. If you do before me feel free to edit it into the answer. – RolandiXor Sep 13 '11 at 20:58
  • 1
    You can always systemctl hibernate – Rolf May 06 '18 at 22:42
4

On Ubuntu Gnome 14.04, Gnome 3.12, the following works (13 June 2014), but I have only set it up to work with pushing the power button and closing the lid (so no GUI button to push).

Credit goes here, to the commentators, too.

Instead of making a new file .../polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla, sudo edit the existing

/var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla

and activate hibernation there, by changing ResultActive=no to ResultActive=yes, to obtain the following sections:

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

[Disable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate
ResultActive=yes

This allows the machine to hibernate.

To activate it on lid closure, sudo edit

/etc/systemd/logind.conf

and change HandleLidSwitch=suspend to #HandleLidSwitch=hibernate.

Before doing this, I searched dconf editor for entries with hibernate and changed everything from suspend to hibernate (my machine cannot resume from suspend...) I'm not sure which entry made it work, but the power button also hibernates my machine now.

Rasmus
  • 8,375
3

There's a bit more required for this in 12.10. (Skip this answer if you're using 12.04 or earlier.) By default, alternative status menu no longer displays the Hibernate option. The easiest way to fix this is to install the extension, newly added to the Ubuntu repositories, and then use gsettings to change the default:

sudo apt-get install gnome-shell-extensions
gsettings set org.gnome.shell.extensions.alternative-status-menu allow-hibernate true

Then enable the extension in Tweak Tool and restart the shell (alt+f2 and enter r).

DO NOT install the extension from extensions.gnome.org.

  • 5
    The second command is not working for me. Are you sure about it? I get this error: No such schema 'org.gnome.shell.extensions.alternative-status-menu' – sajjadG Aug 02 '13 at 11:15
1

For me installing the extension

sudo apt-get install gnome-shell-extensions
gsettings set org.gnome.shell.extensions.alternative-status-menu allow-hibernate true

(as mentioned above) AND editing this file

gksu gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla

and inserting

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

helped (see here).

user178073
  • 11
  • 1
1

You need to install "gnome-shell-extensions-alternative-status-menu" package if you are using gnome-shell testing ppa. This will enable hibernation option as well as power off options in the status menu.

  • 1
    There is no such package in the official repositories which are what I'm using. – dv3500ea Sep 13 '11 at 20:54
  • you need to add the following ppa: sudo apt-add-repository ppa:ricotz/testing && sudo apt-get update. Then upgrade gnome-shell using sudo apt-get dist-upgrade and then install "gnome-shell-extensions-alternative-status-menu" package. That's it – Syed Khalil Sep 14 '11 at 08:58
1

I found a new extension which adds a new button for hibernation. It works fine with touch screens and convertibles because it is a separate button. There is on drawback though: it does not (currently) work from the lockscreen.

enter image description here

It was easy to find in Ubuntu 17.10, I just had to search for hibernate and select the corresponding result of the section for software results. Hibernate and Gnome extensions were already set up, if you have problems with these I suggest you look for the corresponding Q&A here at this site.

Also you can still configure the power button to hibernate your computer instead of shutting it down (settings > power options), if that is what you want.

LiveWireBT
  • 28,763
  • This one worked for me on Ubuntu 18.04 after editing /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla (see https://askubuntu.com/a/1064114/674319) – Laurenz Aug 16 '19 at 21:04
0

For GNOME, on any distro, you can add a hibernate button by simply installing the extension System Action - Hibernate .

And done!

Qinsi
  • 647
0

as of 2013-10-24, using Ubuntu-Gnome 13.10, the following allowed me to use hibernation in the power settings, as well as hibernate using the physical power button:

sudo -i  # because the following should be ran as root
gsettings set org.gnome.shell.extensions.alternative-status-menu allow-hibernate true
cat > /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla <<EOF
[Enable Hibernate]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
EOF
chag
  • 1