Bug 459902

Summary: Update logind.conf while setting lid actions from systemsettings
Product: [Applications] systemsettings Reporter: retired <pepko94>
Component: kcm_powerdevilAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: wishlist CC: jpetso, kde, kde, natalie_clarius, nate, xaver.hugl
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description retired 2022-10-01 20:12:44 UTC
So here is some background. I'm using my laptop with lid down, since 32" is more usable than 15". I told systemsettings to ignore the lid switch when it's on running with external power.
Here's the problem, when I tell my system to shutdown while lid is down, it half kills the session and goes to sleep instead. After waking up all I get is a black screen and cursor, restarting sddm gets me fully functional system.

I was puzzled at first, coming from work and I could have sworn that I pressed shutdown in plasma.
Turns out that after session is done, logind takes over (my theory at least) and whatever is in logind.conf takes priority.

After setting "HandleLidSwitch and HandleSuspendKey, just for good measure to "ignore" my system shuts down even with lid down.

Does logind even support what powerdevil with plasma can do? Having multiple options for different power supply states I mean.
Comment 1 Jakob Petsovits 2024-09-13 17:58:56 UTC
> Does logind even support what powerdevil with plasma can do? Having multiple options for different power supply states I mean.

It doesn't, that's a bit unfortunate that we can't cleanly map to systemd concepts. What systemd does have nowadays is HandleLidSwitchDocked and HandleLidSwitchExternalPower, which roughly let you do the same thing as Plasma's power state configuration, but looking at it from a somewhat different angle.

I'm a little wary of writing systemd.conf from PowerDevil natively, it seems feasible to do if we let a KAuth helper write the config to e.g. /etc/systemd/logind.conf.d/90-kde-powerdevil.conf, but also we'll have to think about a good UI for that or whether it would make more sense to somehow get powerdevil to run also by SDDM (without interruption when starting the session).

Also see: https://github.com/systemd/systemd/issues/31119

But there might also be a different issue altogether, because if systemd is told to shutdown, it shouldn't let subsequent inhibitor changes affect this initial choice. Maybe writing logind configuration is only a hack and the real task is to figure out why shutdown doesn't remain shutdown inside logind itself.
Comment 2 Zamundaaa 2024-09-13 18:04:16 UTC
This sounds more like a bug in systemd than anything else, and the underlying issue would not be fixed by using systemd power management in Plasma.
Please make a bug report to systemd about it; it should not sleep (for any reason, not just the lid switch thing) when the system is already shutting down.