68.5 Always On Power Management


Laptops generally aim to reduce their power consumption through sleep and suspend modes. However, sometimes we want to treat a laptop as a server that should never shut down. For example, a retired or superseded laptop can work as a powerful server. The trick here is to ensure the laptop can boot, connect to the network, and remain on without having to log in to any user account. Particularly to also stop the laptop from sleeping when the lid is closed. Ignore Lid Closing To ignore the lid closing event, and so

to retain the on-state of the laptop, edit /etc/systemd/logind.conf to set HandleLidSwitch=ignore. The default is usually to suspend. Then restart the service:

$ grep HandleLidSwitch= /etc/systemd/logind.conf 

$ sudo perl -pi.bak -e 's|#HandleLidSwitch=suspend|HandleLidSwitch=ignore|' /etc/systemd/logind.conf 

$ grep HandleLidSwitch= /etc/systemd/logind.conf 

$ wajig restart systemd-logind

Another suggestion not tried:

# Disable suspend
$ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
# Re-enable suspend
$ sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0