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…
If it works, your problem should be gone with the next update without a need to have this (or any) option in logind.conf.