Prevent Sleep on Lid Close in the Fedora 30 Terminal

One the ideas I’ve been kicking around lately is whether or not to leave OpenMediaVault behind in favor of a vanilla Fedora 30 server on my personal NAS. The main reason for going with OpenMediaVault in the first place was that I wanted an easy to configure Samba server. However, as I’ve adopted Linux full-time outside of gaming, Samba is becoming less and less of a requirement and SFTP is filling in the gap — quite nicely.

The testing phase began when I decided to fire up an older laptop and connect up a couple of USB hard disks to act as my storage. The idea is that I would get all the planning, like scripts and cron jobs, figured out before I ever deploy seriously. I knew I’d run into issues, especially since I’m more of a Debian/Ubuntu guy, but even better, I’ll get reacquainted with the way the Red Hat/Fedora community does things.

I plan on keeping track of my experiences with posts when I have to do things out of the ordinary, and maybe a few of the ordinary things, too.

One of those not-ordinary things has already cropped up. The lid, while open, was preventing the screen from turning off. This wasn’t a big deal, I thought, I’ll just close the lid! So, I try it, head back to my ssh session, and realize it’s died. I check the laptop. Asleep. I open the lid, and it springs back to life! ssh can resume! I realize I have to disable suspend on close, but since this was the server edition, which has no GUI, I had to figure out how to do this from the Terminal. Here’s what I did to accomplish that:

  1. Login and sudo vi /etc/systemd/logind.conf
  2. Find the line HandleLidSwitch=ignore and uncomment it (remove the # at the beginning of the line). If for some reason the line isn’t there, add it to the bottom of the file. Write and quit.
  3. Restart the systemd daemon with sudo systemctl restart systemd-logind

I had honestly expected it to be a bit more involved, but that was it! Close your lid with confidence!

2 thoughts on “Prevent Sleep on Lid Close in the Fedora 30 Terminal

Leave a Reply

Your email address will not be published. Required fields are marked *