I had some trouble to get hibernate (suspend to disk with power off) to work properly on openSUSE 13.2. You can find the problems that I ran into and how I solved them below.
Getting a Boot Menu
Since a while, Linux systems try to hide the fact that they’re Linux. You switch the PC on and after a few seconds, you see a desktop. I hate that. So the first step is to get the boot menu back. Edit
/etc/default/grub and look for
GRUB_TIMEOUT. It’s 0 now, set it 8:
... GRUB_DEFAULT=saved GRUB_HIDDEN_TIMEOUT=8 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=8 ...
Note: You can’t use YaST for this. YaST can only modify
GRUB_HIDDEN_TIMEOUT which is not very useful IMO.
After making these changes, run
grub2-mkconfig as explained at the top of
/etc/default/grub to update Grub 2’s configuration.
See also: GRUB Manual 2.00: Simple configuration
If you tend to get this dialog when you try to hibernate:
then someone else is logged in. In my case, I sometimes have a root shell lying around somewhere or an SSH session. There are two solutions to this problem:
- Hibernate. Wait. Realize that the system won’t hibernate. Log in again. Find the error dialog. Close it. Find the root shell. Log out root. Try again. Don’t forget to mumble curses all the time since it’s 2:00am and you want to go to bed instead of fighting a security policy.
- Tell polkit that if the user in front of the display wants to hibernate, then simply do it!
To do the second, edit the file
/etc/polkit-default-privs.local and append this line:
After making the change, you need to run
/sbin/set_polkit_default_privs to activate the changes; no reboot or relog necessary.
The first word in the line is the operation, the second one is the permissions. The default for
auth_admin:auth_admin:yes which means “ask for root privileges” which makes sense for a server or a shared PC where people connect remotely.
auth_self means “Authentication by the owner of the session that the client originates from is required” which should be good enough for any standalone/private PC.
Related: Polkit man page
Hibernate KDE With a Single Click
Something that I’m missing since a long time is a way to hibernate a KDE desktop at the push of a button. Options from worst to best:
- Open the start menu. Try to navigate to the shutdown options without accidentally closing the menu. Wonder which of the options is the right one for the millionth time. Click and hope for the best.
- Open a root shell, keep it open at all times and run the command
- Use KShutdown
- Allow yourself to execute the command
sudowithout asking for a password. Put
sudo /usr/sbin/pm-hibernateinto a script and wrap the script with an icon on the desktop.
- Issue the hibernate command via shell script and wrap the script with an icon on the desktop.
Options #1 is too cumbersome. #2 wastes too many resources. #3 isn’t standard and I’ve found it increasingly difficult to find the binary for my system. #4 doesn’t lock your screen so anyone able to turn on your computer can mess with it.
So here is how to do #5. First, we need a shell script
$HOME/bin/hibernate with this content:
#!/bin/bash dbus-send \ --session \ --dest=org.freedesktop.PowerManagement \ --type=method_call \ /org/freedesktop/PowerManagement org.freedesktop.PowerManagement.Hibernate
How let’s create a button for the script:
- Make the script executable with
chmod +x $HOME/bin/hibernate
- Right click on the desktop, add applet “Folder View” (German: “Ordner”).
- Create a new folder
$HOME/Hibernateand select this new folder in the settings. That gives you a small window on the desktop that you can size and move – perfect to position our button.
- Right click in the new window and create a shortcut for a program.
- Enter “Hibernate” as name on the first tab.
- On the program tab, select the script.
- Click OK.
- Open the properties for the new shortcut.
- Click the icon to replace it.
- In the new dialog, select “Actions” and search for “hib” which should offer you “system-suspend-hibernate” Click the icon to select it.
- Click OK
- Size and move the folder view to have the button where you want it.
This fixed my hibernation problem, Thanks a lot
Another easy solutuion is to go to the KDE control panel, and in the Keyboard Shortcuts section, go to Global section and set a keyboard shurtcut for Hibernate. That easy!
Thank you very much, I desperately looked for this setting to stop the waste of energy on a multi-user computer due to the inhibited hibernation.