But what if I want to close the lid?

Oct 09, 2025

homelab technical

Laptop lid

I recently turned an old laptop into a home server, and that experience made me think of the picture above 1. If I want my server/laptop quietly sitting in a closet or under my desk, I will have to shut the lid. How can I do that without turning the computer off?

Fortunately, all Linux distributions that run systemd 2 make this problem pretty easy to solve.

In a fresh Ubuntu server install, open /etc/systemd/logind.conf and make a few changes. Uncomment HandleLidSwitch, HandleLidSwitchExternalPower, and HandleLidSwitchDocked, and set the value of each to ignore.

HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore

What are we doing here? We’re just telling systemd-logind, the systemd daemon that manages user sessions and “seats” (where a “seat” is a collection of hardware assigned to users), that we don’t want it to do anything when it sees a SW_LID event appear on the /dev/input/event* device file.

Once these changes are made, you can apply the new systemd-logind configuration file with

$ sudo service systemd-logind restart

Congrats! Now you can close the lid on your self-hosted Linux servers at your new startup.

Sources


  1. I used to think r/ProgrammerHumor was funny as a freshman in undergrad, but as I learned more, the humor revealed itself to be a little too surface-level and a little too “I’m bad at my job” for my liking. ↩︎

  2. And maybe even the ones that don’t! But that is outside the scope of this article. ↩︎