PC power button doesn't shutdown if screen is locked

Hi guys,
I’d like to be able to press the power button on my PC to shutdown my computer without having to wake it up, login then press the button or click the shutdown option, is that possible? I can provide more info if needed

If you go to System Settings → Power Management → Energy Saving there should be an option called “Button events handling” where you can set the power button to shutdown the computer.
If the computer is sleeping you may need to press the power button twice to wake it up and then shutdown.

Thanks for the reply, that only works if I’m logged in, not at the lock screen… Its one of those Linux things where an unauthorized user can’t trigger a shutdown so wondering if KDE has a method or there’s another workaround

In that case you’ll have to add an authorisation rule in PolicyKit to allow anyone to start a shutdown.
I don’t know the syntax for writing those rules but there should be guides elsewhere on how to write one.

1 Like

Thanks that sounds like a step in the right direction I’ll do some reading on policykit

Yes, this is 392798 – Power button actions should be handled from lock screen. No Polkit stuff should be required since while the lock screen is visible, the user is currently logged in, so their permissions should be preserved and available.

Also… we’re talking about pressing the physical buttons on the computer, so security is kind of moot. :slight_smile:

1 Like

Thanks Nate, yeah i tried Polkit but it didnt work, I’ve done the workaround editing LockScreenUI.qml and that seems to work for now until hopefully it’s added as a feature :slight_smile:

Can you share your edits? Might be worth upstreaming if it fixes the bug and the changes aren’t a huge hack.

Yep, I just copied what lundibundi and Anatol had written in the linked thread. It would be great if you could add the changes in, Ideally I’d want a full poweroff but suspend is probably a more popular ask (can I replace SuspendToRam with some sort of poweroff function?)

OK yeah, that’s a big hack that we wouldn’t be able to accept. :slight_smile: The right solution would involve something like the lock screen de-registering itself as a handler for the power button so that the existing logic to handle it can work normally.

1 Like

Ah that’s unfortunate… Whats the next step is it likely that the dev team will try and address the issue/feature?

Ideally there would be a toggle in power or lock screen settings saying allow shutdown/suspend from lock screen when button is pressed, without too much thought about what that looks like in the back-end :slight_smile:

Someone just needs to put in the time to do it, I think.