Suspend when closing the lid during the shutdown process

Hello everyone,

I found a weird problem with openSUSE Tumbleweed on my laptop (ThinkPad T420s) . As the title saying, the system will suspend when I close the laptop lid after I selecting to shutdown the system but the system has not finished the power off process. And in the Power Saving settings, the behaviour of closing the lid is chosen to be “Lock screen”.

Detailed steps are,

  1. Make sure the behaviour of closing the lid is chosen to be “Lock screen” in Power Saving;
  2. Kick start -> Power -> Shut Down
  3. Close the lid right away
  4. The laptop goes suspend
  5. Open the lid
  6. Laptop resumes from suspend
  7. Shutdown process continues.

Could anyone please shed some light on this? I mean, it seems not right for the system to turn into suspend in the process of shutting down. What’s wrong with it? How could I set it right? I am in the habit to close the lid after issuing the shutdown command. And this problem troubles me a lot.

Cheers

You say you shutdown the system and instantly close the lid? What happens if you wait until the system has completely shut down? It just takes seconds and then I would close the lid, making sure the computer is off.

It would probably help to change systemd/logind’s settings.
Add this to /etc/systemd/logind.conf to disable logind suspending the system when no desktop is running :

HandleLidSwitch=ignore

Though I would consider it a bug (in systemd) if closing the lid during shutdown suspends the system…
Or does this happen while the desktop is still running?

PS: this may be the same issue as discussed in https://forums.opensuse.org/showthread.php/521010-Recent-update-changed-lid-switch-behaviour-How-to-undo
AFAICS the fix is not in Tumbleweed yet either.

If so, setting “LidSwitchIgnoreInhibited=no” would be the proper fix.
Or wait for the next systemd update which should have it fixed.

Yes, you’re right. The laptop can turn off correctly if the lid is left open. And that’s what I did these days. But I still think this is not a right behaviour.

Thanks a lot wolfi323. This works very well.

Yes, I read this post, too. But I cannot understand the situation. And my problem occurs only when I issued shutdown command and close the lid instantly. So my subconscious told my it’s irrelevant. Now it seems they are caused by the same reason.

I’ll try this later since your first suggestion works excellently. Thanks again for your kind help.

Definitely not.

Thanks a lot wolfi323. This works very well.

Ok, so it is indeed systemd’s logind that suspends the system.

Yes, I read this post, too. But I cannot understand the situation.

I’ll try to explain:
Normally, logind (part of systemd) handles such events like closing the lid. Its behavior can be configured in /etc/systemd/logind.conf, the default for lid switch is “suspend” (as is probably expected).

Now if you start a desktop like KDE/Plasma5, it has its own powermanagement. So it “inhibits” (i.e. turns off) logind’s handling of those events, to be able to use its own settings.

But a wrong change in systemd caused this inhibition to no longer work with the default logind.conf settings (for lid switch at least), so KDE in fact cannot handle those events nor apply its settings.

It is about the LidSwitchIgnoreInhibited option, which defaults to yes.
Currently this makes logind also ignore a desktop’s inhibition, which it shouldn’t.

The next systemd update should have this change reverted, so KDE will be able to “take over” again.

And my problem occurs only when I issued shutdown command and close the lid instantly. So my subconscious told my it’s irrelevant. Now it seems they are caused by the same reason.

So you close the lid when the desktop is still there, right?
Apparently that’s “too early” then.

Probably logind is not yet informed of the shutdown, because KDE has not finished yet.
And because logind handles the lid switch (because of the mentioned bug), it suspends.

I think if the actual shutdown would already be progressing, logind wouldn’t suspend but rather let the shutdown finish.
But as it doesn’t know (yet) that the system is to be shut down, it will suspend according to its settings (HandleLidSwitch in logind.conf).

I’ll try this later since your first suggestion works excellently. Thanks again for your kind help.

It should, as this will allow KDE to handle the lid switch again.
But don’t forget to remove “HandleLidSwitch=ignore” too, otherwise you probably won’t be able to tell whether this helps or not… :wink:
If it works, your problem should be gone with the next update without a need to have this (or any) option in logind.conf.

Hi wolfi323, your explanation is simple and informative. Now I get it. The problem is caused by the cooperation problem between systemd and Plasma.

Yes, I closed the lid while OS was still busy in killing all the running applications.

LidSwitchIgnoreInhibited=no

This alone works, too. Your theory is completely right on this.

Ok, I will keep logind.conf intact and wait for the next systemd update.

Thanks again, wolfi323, for your generous help and explaining. I leant a lot from you. Most of my questions here are answered by you :slight_smile: