No way to properly ignore lid close on laptop running as server

I’m using an old laptop as a home server. It cuts (at least) the network connection when I close the lid without being logged in.

I’ve tried using

systemd.targets.sleep.enable = false;
services.logind.lidSwitch = "ignore";

and successfully kept the device from going to sleep. But, as you can imagine, the network cut is quite the issue.

I know of hacks like enabling auto-login, but I’m not ready to do this as (as far as I understand) that’ll let anyone with physical access to the machine use it. Sure, I could create a useless dummy user, but frankly, there must be a better way. Know of any?

1 Like

I’ve had this config when I’ve used my laptop as a server:

{
  services.logind = {
    lidSwitch = "ignore";
    lidSwitchDocked = "ignore";
    lidSwitchExternalPower = "ignore";
    extraConfig = ''
      IdleAction=ignore
      HandlePowerKey=ignore
      HandleSuspendKey=ignore
    '';
  };
}

I’d suggest you to take a look at the journal to understand what’s really going on.

3 Likes