You can suspend from the terminal with:
sudo pm-suspend
In some cases, calling pm-suspend
directly can cause problems with wi-fi drivers and other programs. Moreover, the man page for pm-suspend
says that while it is ok to call it from the command line, it's normally intended to be called through your desktop power manager.
The man page adds that when called from the command line, "it is not guarenteed that all of your programs in your desktop session keep working as expected."
Most of the problems seem to be from services or modules not stopped or unloaded before the suspend. For a good discussion of this issue, along with ways to work around it, see Suspend to Ram in the Arch wiki.
The Arch Wiki also suggests allowing a particular user to run pm-suspend
without sudo
through visudo
to add the following line to /etc/sudoers
:
username ALL = NOPASSWD: /usr/sbin/pm-suspend
LXDE uses the xfce4-power-manager
, which uses pkexec
to call pm-suspend
. pkexec
allows execution of a program as another user, in this case root
.
The authentication is handled by polkit
. It would normally prompt for a password, but as I learned from pkexec with no password it is possible to suppress this through a file in /usr/share/polkit-1/actions
.
There's a file there called org.freedesktop.upower.policy
(upower
is involved in calling pm-suspend
but I left it out for simplicity).
This file contains the line <allow_active>yes</allow-active>
, which is what allows the action to proceed without asking for a password.
Power-related actions are much more complicated than locking the screen or bringing up the menu. It may be better to use the suspend option in the power manager.
If your suspend function-key works, you might find that convenient. If it doesn't appear to work at first, check the settings in the power manager. In Lubuntu, the sleep button is not set to suspend by default.
You may also enjoy working through the issues at the Arch page in order to use pm-suspend
directly. But be careful. I've used the command directly on several other laptops with no problem. On this particular laptop (Lenovo S10-3) it killed the wifi driver. I had to unplug the CMOS battery to get it working again.
pm-suspend
eventually, but with some specific params. Is that correct? – vucalur Oct 23 '14 at 18:45pkexec pm-suspend
. It should not put up an authentication box. To my memory, on my recent Lubuntu installxfce4-power-manager
was activated by default. And it's on the list of installed tools and preferences in the Lubuntu docs. – chaskes Oct 29 '14 at 13:52pm-suspend
doesn't seem to exist on Lubuntu Bionic Beaver. – zrajm Apr 07 '19 at 18:16