Bug 348529 - When screen is locked, turn off screen with a shorter timeout
Summary: When screen is locked, turn off screen with a shorter timeout
Status: RESOLVED FIXED
Alias: None
Product: Powerdevil
Classification: Plasma
Component: general (show other bugs)
Version: 5.26.5
Platform: openSUSE Linux
: HI wishlist
Target Milestone: ---
Assignee: Plasma Development Mailing List
URL: https://forum.kde.org/viewtopic.php?f...
Keywords:
: 393273 407261 424504 427441 441175 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-06-01 00:35 UTC by Rewarp
Modified: 2024-05-12 20:05 UTC (History)
43 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0
Sentry Crash Report:
kde: Usability?


Attachments
Script to turn off screen after locking. (278 bytes, application/x-shellscript)
2015-06-01 16:34 UTC, Rewarp
Details
Script to turn off screen after lock (466 bytes, application/x-shellscript)
2015-06-01 18:14 UTC, Rewarp
Details
Shorten screen power off timeout when screen is locked (976 bytes, application/x-shellscript)
2023-02-03 18:23 UTC, Chris
Details
Bug fix sample (346.88 KB, image/png)
2023-03-04 19:10 UTC, jonathan haney
Details
Timeout of 10s (83.30 KB, image/png)
2023-12-27 07:49 UTC, D. Debnath
Details
klockscreen.sh: "Self-Installing" script to configure screen off delay using notifications hooks (2.89 KB, application/x-shellscript)
2024-05-12 20:05 UTC, Eugene San
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rewarp 2015-06-01 00:35:30 UTC
Since locking the screen means no interaction with the computer, it would be more natural for there to be a time-out feature for the screen to turn itself off after a set amount of time, to save energy.

The following code was contributed by luebking on the KDE forums which can implement this feature. I hope that there will be a simple GUI toggle for this feature in future versions of the lock screen or power management settings.

[code]
qdbus org.freedesktop.ScreenSaver /org/freedesktop/ScreenSaver Lock
sleep 20
if [ "`qdbus org.freedesktop.ScreenSaver /org/freedesktop/ScreenSaver GetActive`" = "true" ]; then
   xset dpms force off
fi
[/code]

Reproducible: Always
Comment 1 Rewarp 2015-06-01 16:34:22 UTC
Created attachment 92948 [details]
Script to turn off screen after locking.
Comment 2 Rewarp 2015-06-01 16:35:29 UTC
Updated based on new code from luebking. I have attached the script file generated from the exercise for testing.
Comment 3 Rewarp 2015-06-01 18:14:13 UTC
Created attachment 92950 [details]
Script to turn off screen after lock

New version which improves on the previous one from luebking. Bug fix and automatically calls DPMS settings.
Comment 4 Kai Uwe Broulik 2015-06-01 19:47:41 UTC
That script isn't particularly efficient.
I like the idea of reducing the timeout for turning off the screen when it's locked (and/or making that a separate option since you might not want it to turn off at all while not locked), though. I added it to my todo list. Thanks.
Comment 5 Nick 2015-08-28 15:58:31 UTC
This doesn't work.
Yes, it turns off the screen, but something turns it back on just a second later.

Doing
sleep 5; xset dpms force off
then quickly clicking the lock button yields the same result--it goes to screen saver, turns off, then turns right back on.

In short, currently there is no way to get the screen into power save mode with the kde screen locked.
Comment 7 Rewarp 2015-08-29 02:02:13 UTC
I have been using this script since the day I uploaded it, and on a newly reinstalled desktop as well. I am running an ATI card using the DVI port, so that could be the difference.
Comment 8 kraeutermann 2015-08-29 11:24:32 UTC
On Kubuntu 15.04 running Plasma 5.3.2 it returns:

Service 'org.freedesktop.ScreenSaver' does not exist.
lcsleep.sh: 11: lcsleep.sh: [[: not found

Not working.
Comment 9 Nick 2015-08-31 22:09:59 UTC
related to #349344 ?
Comment 10 Nick 2015-09-26 22:22:16 UTC
My case seems to have been because of a bug in the nvidia-drivers.
https://bugs.gentoo.org/show_bug.cgi?id=560774
Comment 11 Lukas Ba. 2017-01-01 22:00:07 UTC
A better workaround:
Go to System Settings > Notifications > Event Source: Screen Saver
Click on "Screen locked"
Enable "Run command" and copy this into the text box:
/usr/bin/sleep 2.0 && /usr/bin/xset dpms force off
Comment 12 Kai Uwe Broulik 2017-01-02 00:15:32 UTC
So, Martin, and Usability, what do you think about this?

Looks like we have three options:
1.) Add option to turn off screen when user locks it
2.) Add option to reduce turn off timeout when screen is locked (to e.g. 30 seconds or 1 minute) ← would be my preference
3.) Keep it as it is

(I was just thinking of the phone usecase, too, but currently pressing the power button directly turns off the screen independently of the lock screen?)
Comment 13 Martin Flöser 2017-01-02 06:41:29 UTC
Some thoughts from using my system. I often listen to music provided by 
the computer. The computer's audio is connected through HDMI to one of 
my screens. When the screen goes into DPMS the audio is turned off with 
a loud *knacks* and when being turned on again it *knacks* again.

When I listen to music I hate it when the system goes into DPMS.

Even worse, though, is that the screen is very slow when going into DPMS 
or returning from it. The screen needs a fair 10 sec or more to do the 
mode switch. And it cannot handle it correctly. After resume from DPMS 
I'm greeted with a message that "invalid mode is used", while in truth 
everything is correct. To get rid of the message I need to press the 
menu button of the screen.

The screen is about 5/6 years old.

I'm telling this just to make aware that not all users would benefit 
from instant turning on DPMS when going to lock the screen. It can be 
highly annoying.

Given that we must have an option for it. I do see the energy saving 
aspect and would suggest to reduce the timeout to 30 sec after the 
screen is locked. But if DPMS is broken the normal energy saving levels 
should be used. We do support things like audio control in the lock 
screen. This doesn't make sense if the system goes into DPMS every half 
a minute.

Also we need to be careful. We only should do this if the screen gets 
locked either explicitly by the user or through idle timeout. Not when 
switching user session or going to suspend.
Comment 14 Lukas Ba. 2017-01-03 18:25:57 UTC
If you set the lockscreen timeout to less than the DPMS timeout (-30s), that effectively reduces the DPMS timeout to the lockscreen timeout (+30s), making the DPMS timeout setting ineffective. this must somehow be communicated.
Comment 15 gadelat 2018-05-09 22:10:51 UTC
gnome-shell does this natively. In KDE, user is still forced to write a script for this and attach it to lock screen even notification trigger.
Comment 16 Peter 2018-07-04 07:50:28 UTC
Is this included in any roadmap for a future release?  This is a key feature for me.
Comment 17 arne anka 2019-03-11 10:06:33 UTC
surprising such a trivial but vital feature is still missing - and nothing happened after almost 4 years.
Comment 18 Kai Uwe Broulik 2019-03-11 10:25:19 UTC
If it were trivially implemented, I would have long done it. Feel free to poke the code and submit a patch, relevant code can be found in powerdevil/daemon/actions/dpms
Comment 19 goodmirek 2019-03-11 10:58:31 UTC
arne anka: The issue seems to be there is not enough people able to contribute their manpower or money to buy such a manpower.
If I create an issue for this bug on bountysource.com and add $50 bounty, how much will you contribute?
Comment 20 Lukas Ba. 2019-03-11 16:54:25 UTC
> 2.) Add option to reduce turn off timeout when screen is locked (to e.g. 30 seconds or 1 minute) ← would be my preference

Here is how to implement this behaviour with the event workaround.
I added two commands. To reduce the delay until the screen is turned off, when the screen is locked.
/usr/bin/xset dpms 69
To reset the delay until the screen is turned off to the longer value, when the screen is unlocked.
/usr/bin/xset dpms 420
Comment 21 arne anka 2019-03-12 09:10:52 UTC
(In reply to Kai Uwe Broulik from comment #18)
> If it were trivially implemented, I would have long done it. Feel free to
> poke the code and submit a patch, relevant code can be found in
> powerdevil/daemon/actions/dpms

I am not a C++/Qt programmer.
But if a feature that common in other DMs (and frankly in the light of longtime and ongoing discussions about global warming etc very sensible feature) is that difficult to implement, then there seems to be a broken design at the core.
Comment 22 arne anka 2019-03-12 09:12:35 UTC
(In reply to goodmirek from comment #19)
> arne anka: The issue seems to be there is not enough people able to
> contribute their manpower or money to buy such a manpower.
> If I create an issue for this bug on bountysource.com and add $50 bounty,
> how much will you contribute?

@goodmirek: well, I'm prepared to offer between 50 and 100.
Comment 23 Christoph Feck 2019-03-12 12:03:30 UTC
Comment #11 works perfect for me.
Comment 24 Nate Graham 2019-03-17 14:07:33 UTC
*** Bug 405344 has been marked as a duplicate of this bug. ***
Comment 25 goodmirek 2019-04-08 10:33:51 UTC
(In reply to arne anka from comment #22)
> (In reply to goodmirek from comment #19)
> > arne anka: The issue seems to be there is not enough people able to
> > contribute their manpower or money to buy such a manpower.
> > If I create an issue for this bug on bountysource.com and add $50 bounty,
> > how much will you contribute?
> 
> @goodmirek: well, I'm prepared to offer between 50 and 100.

I have just created an issue for this bug on bountysource.com and added $50 bounty.
Please feel free to make your contributions here:
https://www.bountysource.com/issues/72539369-turn-off-screen-after-lock-screen
Comment 26 goodmirek 2019-04-08 10:39:20 UTC
(In reply to Nate Graham from comment #24)
> *** Bug 405344 has been marked as a duplicate of this bug. ***

The bug 405344 is not a duplicate of this bug 348529, although it is related. The bug 405344 might need to be solved in order to make a fix for this bug 348529 working.
Comment 27 arne anka 2019-04-16 16:24:12 UTC
(In reply to goodmirek from comment #25)
> (In reply to arne anka from comment #22)
> > (In reply to goodmirek from comment #19)
> > > arne anka: The issue seems to be there is not enough people able to
> > > contribute their manpower or money to buy such a manpower.
> > > If I create an issue for this bug on bountysource.com and add $50 bounty,
> > > how much will you contribute?
> > 
> > @goodmirek: well, I'm prepared to offer between 50 and 100.
> 
> I have just created an issue for this bug on bountysource.com and added $50
> bounty.
> Please feel free to make your contributions here:
> https://www.bountysource.com/issues/72539369-turn-off-screen-after-lock-
> screen

Got only just now to checking out bountysource.com -- they only offer PayPal, and PayPal is a No-Go. I wouldn't touch that particular company with a ten-foot-pole.
If you have an idea how I can add my share in a sane and trustworthy way, let me know.
Comment 28 goodmirek 2019-04-17 04:56:17 UTC
(In reply to arne anka from comment #27)
> (In reply to goodmirek from comment #25)
> > (In reply to arne anka from comment #22)
> > > (In reply to goodmirek from comment #19)
> > > > arne anka: The issue seems to be there is not enough people able to
> > > > contribute their manpower or money to buy such a manpower.
> > > > If I create an issue for this bug on bountysource.com and add $50 bounty,
> > > > how much will you contribute?
> > > 
> > > @goodmirek: well, I'm prepared to offer between 50 and 100.
> > 
> > I have just created an issue for this bug on bountysource.com and added $50
> > bounty.
> > Please feel free to make your contributions here:
> > https://www.bountysource.com/issues/72539369-turn-off-screen-after-lock-
> > screen
> 
> Got only just now to checking out bountysource.com -- they only offer
> PayPal, and PayPal is a No-Go. I wouldn't touch that particular company with
> a ten-foot-pole.
> If you have an idea how I can add my share in a sane and trustworthy way,
> let me know.

Bountysource.com might be able to accept donations in ETH.

Anyway, the conditions did not change since me and arne anka made an agreement to make a donation. I have kept my part of the promise.
I believe anyone who wants to complain about a state of any FOSS project should first contribute their effort and/or money.
Comment 29 Kai Uwe Broulik 2019-05-06 07:03:24 UTC
*** Bug 407261 has been marked as a duplicate of this bug. ***
Comment 30 Patrick Silva 2020-07-21 21:28:52 UTC
*** Bug 424504 has been marked as a duplicate of this bug. ***
Comment 31 Lukas Ba. 2020-08-26 23:01:30 UTC
It's been 5 years since this bug was opened. Can we please just use the event script solution i suggested? This should be as simple as editing some default configuration files to add the xset commands below.

To reduce the delay until the screen is turned off, when the screen is locked.
Go to System Settings > Notifications > Event Source: Screen Saver
Click on "Screen locked"
Enable "Run command" and copy this into the text box
/usr/bin/xset dpms 69
To reset the delay until the screen is turned off to the longer value, when the screen is unlocked.
/usr/bin/xset dpms 420
Comment 32 Patrick Silva 2020-10-08 20:09:17 UTC
*** Bug 427441 has been marked as a duplicate of this bug. ***
Comment 33 Chris 2021-05-13 23:46:50 UTC
I've tried the following on debian sid with Plasma 5.21, Framework 5.82, and most importantly Wayland:

$ cat ./kde-saver-script.sh 
#! /bin/bash
# https://unix.stackexchange.com/questions/353998/run-script-on-screen-lock-in-kde
# Run the script in a terminal and then type Ctrl+Alt+L, and then the screen should turn off after only 60 sec.
# Once you unlocked the screen, the turn off screen timer is set back to 600 sec.
dbus-monitor --session "type='signal',interface='org.freedesktop.ScreenSaver'" |
  while read x; do
    case "$x" in
      *"boolean true"*)
        echo SCREEN_LOCKED;
        kwriteconfig5 --file powermanagementprofilesrc --group AC --group DPMSControl --key idleTime 60;
        qdbus org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement org.kde.Solid.PowerManagement.refreshStatus
        ;;
      *"boolean false"*)
        echo SCREEN_UNLOCKED;
        kwriteconfig5 --file powermanagementprofilesrc --group AC --group DPMSControl --key idleTime 600;
        qdbus org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement org.kde.Solid.PowerManagement.refreshStatus
        ;;
    esac
  done

And it works, very well indeed. But sometimes, even though it worked when you left the room, when you come back you find the screen turned on, and stubbornly refusing to turn off all by itself.
Consistency is of the essence here: save the planet, turn off the screen.

Even though it's not working, the "turn off screen" seems much more consistent with Wayland than it was with x11.
(https://blog.martin-graesslin.com/blog/2015/09/comparing-dpms-on-x11-and-wayland/)

And maybe obvious improvements to the script could fix it.

Note that I did do `sudo systemd-inhibit --list`, when I observed the "turn off" action was failing, but nothing stuck out. So I have no idea on what went wrong.

However the "turn off screen" thing seems consistent without my script meddling into it, and only the settings in "power management / energy saving". So it is likely that the poor script above is missing some mandatory settings.
Comment 34 Chris 2021-08-08 19:29:52 UTC
The script above should work nicely, but it doesn't, not consistently at least.
Related bugs:
https://bugs.kde.org/show_bug.cgi?id=348082 "monitor is randomly powered back on"
https://bugs.kde.org/show_bug.cgi?id=422455 "Monitor power saving won't work when using DisplayPort cable"
Comment 35 Nate Graham 2021-08-19 20:28:26 UTC
*** Bug 441175 has been marked as a duplicate of this bug. ***
Comment 36 Mohammad K. 2022-05-09 16:14:47 UTC
This bug is kind of annoying. Is there any problem about not solving it? Since this is small bug. It's not resolved for 7 years!
I think the only thing to do is to add an option for lock screen timeout in the power settings.
Comment 37 Chris 2022-05-29 20:19:37 UTC
(In reply to Chris from comment #34)
> The script above should work nicely, but it doesn't, not consistently at
> least.
> Related bugs:
> https://bugs.kde.org/show_bug.cgi?id=348082 "monitor is randomly powered
> back on"
> https://bugs.kde.org/show_bug.cgi?id=422455 "Monitor power saving won't work
> when using DisplayPort cable"

Those two bugs no longer bother me, for a few month now, latest debian-sid, wayland as pure as possible.
Comment 38 Chris 2022-05-29 20:28:31 UTC
(In reply to mágoa mångata from comment #36)
> This bug is kind of annoying. Is there any problem about not solving it?
> Since this is small bug. It's not resolved for 7 years!
> I think the only thing to do is to add an option for lock screen timeout in
> the power settings.

Have you tried the `kde-saver-script.sh` script from above? My system is now so well behaved in that regard that I don't need that anymore. But I believe that should work just fine. And that both with x11 (which I no longer use), and wayland.
Comment 39 Mohammad K. 2022-05-30 05:32:23 UTC
(In reply to Chris from comment #38)
> (In reply to mágoa mångata from comment #36)
> > This bug is kind of annoying. Is there any problem about not solving it?
> > Since this is small bug. It's not resolved for 7 years!
> > I think the only thing to do is to add an option for lock screen timeout in
> > the power settings.
> 
> Have you tried the `kde-saver-script.sh` script from above? My system is now
> so well behaved in that regard that I don't need that anymore. But I believe
> that should work just fine. And that both with x11 (which I no longer use),
> and wayland.

I know it works. But the thing is, it should be implemented in the settings and be turned on by default. So no one would be annoyed.
Comment 40 Chris 2022-07-30 03:11:15 UTC
(In reply to Kai Uwe Broulik from comment #4)
> That script isn't particularly efficient.
> I like the idea of reducing the timeout for turning off the screen when it's
> locked (and/or making that a separate option since you might not want it to
> turn off at all while not locked), though. I added it to my todo list.
> Thanks.

What do you think of the script there https://bugs.kde.org/show_bug.cgi?id=348529#c33?
It does not, on the face of it, rely on an infinite loop, and it works both with x11 and wayland.

dbus-monitor --session "type='signal',interface='org.freedesktop.ScreenSaver'" |
  while read x; do
    case "$x" in
      *"boolean true"*)
        echo SCREEN_LOCKED;
        kwriteconfig5 --file powermanagementprofilesrc --group AC --group DPMSControl --key idleTime 60;
        qdbus org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement org.kde.Solid.PowerManagement.refreshStatus
        ;;
      *"boolean false"*)
        echo SCREEN_UNLOCKED;
        kwriteconfig5 --file powermanagementprofilesrc --group AC --group DPMSControl --key idleTime 600;
        qdbus org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement org.kde.Solid.PowerManagement.refreshStatus
        ;;
    esac
  done

It is quick and dirty cut and paste but I think it works, and I don't see why not?

As they say in https://bugs.kde.org/show_bug.cgi?id=348529#c39, it could help having something like that integrated in System-Settings, instead on relying on users hacks.

It is annoying having 30W plus, of monitor LED, glowing unnecessarily. (https://www.thehomehacksdiy.com/how-much-power-watts-does-a-monitor-use/)

Keep in mind that for most users, monitor power button is not an option because it scrambles up all the settings.
Comment 41 Johan Manuel 2022-10-31 20:54:24 UTC
*** Bug 338501 has been marked as a duplicate of this bug. ***
Comment 42 Aleix Pol 2022-11-04 19:08:44 UTC
I'm sorry, I was just pointed to this MR and am not sure what the problem exactly is. 

Shouldn't the default mechanisms from PowerDevil kick in here and eventually dpms=off the screen?

One thing that the new changes offer is that the script can be switched to use "kscreen-doctor --dpms off" instead of messing with the powerdevil profiles.

Also you can press Esc to dim the screen, although I understand this isn't exactly what we're after here.
Comment 43 Chris 2022-11-05 18:59:12 UTC
(In reply to Aleix Pol from comment #42)
> I'm sorry, I was just pointed to this MR and am not sure what the problem
> exactly is. 
> 
> Shouldn't the default mechanisms from PowerDevil kick in here and eventually
> dpms=off the screen?
> 
> One thing that the new changes offer is that the script can be switched to
> use "kscreen-doctor --dpms off" instead of messing with the powerdevil
> profiles.
> 
> Also you can press Esc to dim the screen, although I understand this isn't
> exactly what we're after here.

I think the point is to have two different "screen energy saving" timers, one for the plain idle session, and the other for when the screen is locked. I think every device but kde/plasma has this feature nowadays: https://learn.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/monitor-powers-off-when-pc-locked, also android, gnome iiuc; the Phosh timer in this circumstance is so short that unlocking the screen is challenging...

I think the script above does just that, it did prove useful, but I'm not sure it's robust at all. And it's a lot of tinkering. (https://bugs.kde.org/show_bug.cgi?id=348529#c33)

The new command "kscreen-doctor --dpms off" is awesome for wayland users, but I think it's more about the timer, just as expressed with the new name: "turn screen off at some point".
Comment 44 Bug Janitor Service 2022-11-06 01:05:22 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/116
Comment 45 Chris 2022-11-08 02:53:13 UTC
(In reply to Bug Janitor Service from comment #44)
> A possibly relevant merge request was started @
> https://invent.kde.org/plasma/powerdevil/-/merge_requests/116

The merge request is about "dimming" the screen. It's also about people wanting to "watch their screensaver for a while". A lot of fancy things.
It is completely unrelated to "turn off screen".
Additionally screen dimming is only relevant for laptop screen.
All in all the two issues are completely unrelated.
Comment 46 wazhai 2023-01-28 13:37:36 UTC
I think it would be more straightforward to implement this as part of kscreenlocker.

Recently kscreenlocker gained the ability to manually turn off monitors by pressing Escape: https://invent.kde.org/plasma/kscreenlocker/-/merge_requests/99

I think kscreenlocker should leverage the same mechanism used in the above merge request to also automatically turn off monitors after a shorter time while locked, without involving or needing any changes in powerdevil at all. This could be configured in the kscreenlocker KCM as "turn off displays while locked after X minutes" (and in Power Saving KCM routed to kscreenlocker if needed)

Any thoughts about reassigning this to kscreenlocker? There must be a reason why it hasn't been implemented under powerdevil for a long time, so what about approaching the implementation through kscreenlocker?

(I have created Bug 393273 which is pretty much a duplicate of this one that I discovered today)
Comment 47 Nate Graham 2023-02-02 20:24:07 UTC
*** Bug 393273 has been marked as a duplicate of this bug. ***
Comment 48 Bug Janitor Service 2023-02-03 12:19:56 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreenlocker/-/merge_requests/126
Comment 49 wazhai 2023-02-03 13:55:07 UTC
I have changed the bug summary/title to clarify the essence of this feature request, because "turn off at some point" is already the case.
Comment 50 Chris 2023-02-03 18:23:51 UTC
Created attachment 155925 [details]
Shorten screen power off timeout when screen is locked
Comment 51 jonathan haney 2023-03-04 19:10:57 UTC
Created attachment 156995 [details]
Bug fix sample

Looks like the last attempt got shot down by the maintainers.
So out of curiosity I spent a few hours and have a local fix with some changes around dpms.cpp/h dpmsconfig.cpp/h
I adding an extra timer and the GUI controls seen in the attachment above.
I think I spent more time figuring out how to test this and handling dependencies vs actually writing code :P
If people think the interface is good I'll go jump some hoops to figure out how to put in the merge request.
Comment 52 Bug Janitor Service 2023-03-05 19:37:13 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/142
Comment 53 Jeff 2023-03-05 23:35:00 UTC
(In reply to jonathan haney from comment #51)
> Created attachment 156995 [details]
> Bug fix sample
> 
> Looks like the last attempt got shot down by the maintainers.
> So out of curiosity I spent a few hours and have a local fix with some
> changes around dpms.cpp/h dpmsconfig.cpp/h
> I adding an extra timer and the GUI controls seen in the attachment above.
> I think I spent more time figuring out how to test this and handling
> dependencies vs actually writing code :P
> If people think the interface is good I'll go jump some hoops to figure out
> how to put in the merge request.

Thank you for this!
Out of curiosity, will you be able to only enable screen power off when locked without enabling it for a logged in session.
Session Locked -> power save after X minutes.
Session ! Locked -> power save never.
Comment 54 jonathan haney 2023-03-06 00:19:50 UTC
Sadly the short answer is no.
TBH I didn't think anyone that would want "Switch off after" disabled but "Switch off while locked" enabled.
Allowing "Switch off after" to be set to 0 would be trivial and would allow for this behavior but I haven't traced its usage fully so I'm not super confident in it not causing new issues atm.
However, now that I think about it I'm pretty certain they'll ask me to move the code out of dpms and make a special home for it elsewhere.
If so it might be a few weeks before I can resubmit due to health issues but you'll probably end up getting that behavior sooner than 8 years.
Comment 55 Michel Filipe 2023-05-04 15:54:24 UTC
I'm studying to move from Fedora Gnome to openSuse Tumbleweed KDE and found out this behavior in KDE using a LiveCD. Actually I didn't get why this bug is so irrelevant for KDE (don't see this as a feature but a bug). 

See 3 points where this bug affects the users:

1. Energy consumption once turn off the screen will use the energy efficiently;
2. New displays like OLEDs need to be in the stand-by mode to be able to execute the pixel refresh to avoid burn-in;
3. Don't see logic on allow the display be turned on in a black screen with clock (there is an option to disable the clock) and the cursor. I'm a MacOS and Gnome user, both DE turn off the screen on the lock screen.

@jonathan opened https://invent.kde.org/plasma/powerdevil/-/merge_requests/142 to implement this 1 month ago, pushed a commit and that's it, nothing happen. I see a https://www.bountysource.com/issues/72539369-turn-off-screen-after-lock-screen that I can add $50 as well but I don't think money is the real problem here. 

I wonder what we really need to make this bug relevant to KDE. I'm not a C++ programmer but have two decades of software engineer, so I believe I can implement this with someone mentors me, but I'm vision the problem is motivation and not a new person writing code.
Comment 56 Bug Janitor Service 2023-05-09 15:02:39 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/173
Comment 57 Méven 2023-05-10 12:25:46 UTC
Git commit 914419dc929dec949d8c652962cef18cc7c25b13 by Méven Car, on behalf of Jonathan Haney.
Committed on 10/05/2023 at 12:11.
Pushed by meven into branch 'master'.

When screen is locked, turn off screen with a shorter timeout

Added a "Turn off screen while locked" config under Screen Energy Savings group to allow users to pick a different timeout during screen lock.

M  +19   -0    daemon/actions/bundled/dpms.cpp
M  +1    -0    daemon/actions/bundled/dpms.h
M  +11   -0    daemon/actions/bundled/dpmsconfig.cpp
M  +1    -0    daemon/actions/bundled/dpmsconfig.h

https://invent.kde.org/plasma/powerdevil/commit/914419dc929dec949d8c652962cef18cc7c25b13
Comment 58 D. Debnath 2023-12-23 06:14:08 UTC
This is still not working for me in Plasma 6 (KDE Neon Unstable). Display never turns off when screen is locked.

Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.91.90
KDE Frameworks Version: 5.248.0
Qt Version: 6.6.1
Kernel Version: 6.2.0-34-generic (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-7700HQ CPU @ 2.80GHz
Memory: 23.3 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 630
Comment 59 Jakob Petsovits 2023-12-26 18:43:15 UTC
(In reply to D. Debnath from comment #58)
> This is still not working for me in Plasma 6 (KDE Neon Unstable). Display
> never turns off when screen is locked.

What timeout value are you using for when the screen is locked? There's currently Bug 476962 which causes this to break for locked timeouts of 0 seconds. If it's not that, could you post reproduction steps?
Comment 60 D. Debnath 2023-12-27 07:49:34 UTC
Created attachment 164469 [details]
Timeout of 10s

(In reply to Jakob Petsovits from comment #59)
> What timeout value are you using for when the screen is locked? There's
> currently Bug 476962 which causes this to break for locked timeouts of 0
> seconds. If it's not that, could you post reproduction steps?

I'm using a timeout value of 10s. Please see attached screenshot.

Reproduction steps are simply:

1. Set timeout to any value (10s, 30s, whatever).
2. Lock screen.
3. Wait for 10 seconds (or 30 or whatever is set).
4. Screen does not turn off.

But I should mention that I've noticed that screen does turn off randomly (sometimes) when screen is locked. But it certainly does not happen at the exact set timeout. It's completely random. Sometime it NEVER turns off.

This happens both on my laptop and desktop. Laptop is running Plasma 6.0 Beta 2 in KDE Neon. Desktop is running Plasma 6.0  Beta 1 in Arch Linux. Desktop details:

Operating System: Arch Linux 
KDE Plasma Version: 5.90.0
KDE Frameworks Version: 5.246.0
Qt Version: 6.6.1
Kernel Version: 6.6.7-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 12 × Intel® Core™ i5-10400 CPU @ 2.90GHz
Memory: 7.5 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 630
Comment 61 D. Debnath 2023-12-27 08:46:17 UTC
I rebooted my desktop once. It seems to be working now! Not sure if it will work reliably though. I'll report back after checking again on my laptop.
Comment 62 D. Debnath 2023-12-28 07:05:59 UTC
Okay, seems like this is working in my laptop as well (KDE Neon Plasma 6.0 Beta 2). I'll mark it as resolved.
Comment 63 Méven Car 2024-03-04 14:39:48 UTC
(In reply to D. Debnath from comment #62)
> Okay, seems like this is working in my laptop as well (KDE Neon Plasma 6.0
> Beta 2). I'll mark it as resolved.

Sorry, indeed the setting update is not taken into account without a reboot.
This could be reported as another bug.
Comment 64 Eugene San 2024-05-12 20:05:41 UTC
Created attachment 169403 [details]
klockscreen.sh: "Self-Installing" script to configure screen off delay using notifications hooks

The is fixed in Plasma 6 but for Plasma 5 users, I am attaching klockscreen.sh
"Self-Installing" script to configure screen off delay using notifications hooks.
Place the script anywhere (~/bin or ~/.config) and run run it once with 'install' parameter once.
To disable, just delete it and ~/.config/ksmserver.notifyrc

Details inside.