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:
sudo pm-hibernate
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 sudo
:
- Adding an entry for Hibernate in the Power Off/Log out menu, using
pm-hibernate
. Possibly the preferred alternative. - Have
systemctl hibernate
to actually executesudo pm-hibernate
(and without requiring my password). I guess this would work transparently with the shortcut already assigned tosystemctl hibernate
. - 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-hibernate
shortcut displaying a message box where one can enter the password.
Related: