Fedora Server 40 - Issue Preventing Suspend on Lid Close

Hi all,

I’ve just set up a new F40 Server, and followed the previous instructions on ignoring suspend on lid close (its on a laptop).

They didn’t seem to work at all. First I realised the location of the file to edit had changed, so I found the new location and made the usual edits.

Here is the contents of the file - the server still suspends when the laptop is closed. Please let me know if more information is needed.

Note - I have had earlier versions of Fedora working on this laptop with the lid closed just fine.

Goal: Prevent suspending when laptop lid closed on Fedora 40 Server
File: /usr/lib/systemd/logind.conf

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#UserStopDelaySec=10
#HandlePowerKey=poweroff
#HandlePowerKeyLongPress=ignore
#HandleRebootKey=reboot
#HandleRebootKeyLongPress=poweroff
#HandleSuspendKey=suspend
#HandleSuspendKeyLongPress=hibernate
#HandleHibernateKey=hibernate
#HandleHibernateKeyLongPress=ignore
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#RebootKeyIgnoreInhibited=no
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RuntimeDirectoryInodesMax=
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
#StopIdleSessionSec=infinity

Do not modify anything in /usr unless that’s /usr/local.

sudo tee /etc/systemd/logind.conf << EOF > /dev/null
[Login]
HandleLidSwitch=ignore
EOF
sudo restorecon -F -R /etc/systemd
sudo systemctl restart systemd-logind.service
1 Like

Thank you - that worked! I appreciate it

1 Like

It would be better to do as “man logind.conf.d” says, make a drop-in file for this:

sudo mkdir -p /etc/systemd/logind.conf.d
sudo tee /etc/systemd/logind.conf.d/override.conf << EOF > /dev/null
[Login]
HandleLidSwitch=ignore
EOF
sudo restorecon -F -R /etc/systemd
sudo systemctl restart systemd-logind.service

This way a possible future update of the “systemd” package that itself changes the /etc/systemd/logind.conf won’t conflict with your edit. You’ll have put your edit in the optional /etc/systemd/logind.conf.d/override.conf “drop-in” file. It’s also nicer from a maintenance standpoint, you can find all your local drop-in files with one command with:

find /etc/systemd -type f -name "override.conf"

1 Like

The defaults were moved to /usr/lib in F40, which makes /etc no longer affected by systemd updates and effectively eliminates the main reason for creating extra directories.
Also keep in mind that possible customization under /etc/systemd is not limited to *.conf files.

Then why did my PC last night say:

rpm -qf /etc/systemd/logind.conf

belongs to package “systemd”? My PC was Fedora 42 Beta for that so that’s long past Fedora 40.

UPDATE: I think I see, it’s just a 0 byte file.

rpm -qlv systemd | grep logind.conf$
-rw-r–r-- 1 root root 0 Feb 15 19:00 /etc/systemd/logind.conf
-rw-r–r-- 1 root root 1785 Feb 15 19:00 /usr/lib/systemd/logind.conf

I think on my older laptop that was a real non-zero byte file from an older OS. So I saw content in it when I looked. That’s bad, I suppose I should review each package and delete bogus files like that (make /etc/systemd/logind.conf be an empty file)