Prevent suspend when lid close in Fedora 37

Whenever I close my lid, it goes into suspend mode.

I want it should do nothing when I close it.

I have made following changes in sudo vi /etc/systemd/logind.conf

HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore

In GNOME Tweaks, ’ Suspend when lid is closed ’ is turned off.

But nothing happened.

2 Likes

Added: OK, I see. Strange.

Is that what you want?

I hope that is not what he sees. That image shows suspend is enabled on lid close.

My issue is resoled.

I just ran the following command in terminal -

systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
3 Likes

Thanks, I’ve struggled with the same issue with the exact same initial attempted fixes since installing Fedora on an HP ProBook 4530s. Let’s hope this fixes the problem.

UPDATE: This does indeed solve the problem. Thanks again.

1 Like

For anyone still looking for info on how to configure such a setup I believe there’s a better approach than masking the targets of logind. You can use the HandleX directives in the logind.conf file to achieve the desired effect for each state.

In case you already used the masking solution, you first need to revert the action by unmasking the targets. Try running:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

Then, check the sleep.target to verify it’s active

systemctl status sleep.target

Go ahead and then open the logind.conf file:

sudo nano /etc/systemd/logind.conf

Then find the following directives and set them to the values given below (or any other combination you may want):

HandleLidSwitch=suspend
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore

Restart the service:

sudo systemctl restart systemd-logind

You will be thrown out of your session so make sure you don’t have any unsaved work.

Enjoy.

NOTE:

OP is missing the HandleLidSwitchExternalPower directive.

@pcnoic Thanks, but sleep and suspend aren’t use cases for the affected machine on my end. I just want it to run 24/7/52, which the original solution enables. I never want this machine to be anything other than powered on and ready to go.