Is it possible to prevent my laptop from going to sleep when I close the lid regardless of whether I am logged in?
In /etc/systemd/logind.conf
, I have set each of HandleLidSwitch
, HandleLidSwitchExternalPower
, and HandleLidSwitchDocked
to ignore
. This achieves the desired effect once I have logged in, but if I reboot the machine and close the lid at the GDM login screen, the laptop goes to sleep after a short amount of time.
This is a fresh install of AlmaLinux OS 9.4 using the Minimal ISO downloaded today.
Why do I want this? I am experimenting with an old laptop as a Samba server on my LAN. My goal is to stick the laptop in a closet and minimize the need for manual attention. Samba runs as a system service, so the laptop only needs to be on (not logged in) to work as a Samba server. However, I have set up dnf-automatic
to update and reboot automatically when needed, which means that sometimes the laptop will reboot itself and I will not be logged in. I can tell that the laptop is suspending itself in this case because the Samba share goes offline.