I am using Ubuntu 20.04. I mean to setup a simple way to hibernate, for anyone with no knowledge of Ubuntu/terminal to be able to hibernate.
I tried first setting up
systemctl hibernate, and a Settings -> Keyboard Shortcuts for it. Hibernating this way didn't work well.
So I went the
pm-hibernate way (e.g., this). Now
sudo pm-hiberante works well. So I mean to set up a shortcut for it. I tried assigning the following commands in Settings -> Keyboard Shortcuts, to no avail:
echo <my_password> | sudo -S pm-hibernate(I am a sudoer). Besides the fact it didn't work, this is not a desirable way to do things, since my password becomes exposed, although in this case I could settle for that if need be.
How can I get this working?
Possible routes below. I am not certain how to materialize them, and which of them cannot overcome the need for
- Adding an entry for Hibernate in the Power Off/Log out menu, using
pm-hibernate. Possibly the preferred alternative.
systemctl hibernateto actually execute
sudo pm-hibernate(and without requiring my password). I guess this would work transparently with the shortcut already assigned to
- Allow for any user to
pm-hibernate. As a purist, one would avoid this, although if it solves the issue, it is fine.
- Have the
sudo pm-hibernateshortcut displaying a message box where one can enter the password.
- how to make linux prefer sudo pm-hibernate over systemctl hibernate as default?
- Menu for hibernate does not work, pm-hibernate does
- Force hibernate using hibernate instead of pm-hibernate