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
Created attachment 92948 [details] Script to turn off screen after locking.
Updated based on new code from luebking. I have attached the script file generated from the exercise for testing.
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.
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.
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.
related to: ? https://devtalk.nvidia.com/default/topic/791786/linux/dpms-not-working-on-gtx980-with-displayport-connection/2/
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.
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.
related to #349344 ?
My case seems to have been because of a bug in the nvidia-drivers. https://bugs.gentoo.org/show_bug.cgi?id=560774
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
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?)
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.
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.
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.
Is this included in any roadmap for a future release? This is a key feature for me.
surprising such a trivial but vital feature is still missing - and nothing happened after almost 4 years.
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
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?
> 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
(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.
(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 #11 works perfect for me.
*** Bug 405344 has been marked as a duplicate of this bug. ***
(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
(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.
(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.
(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.
*** Bug 407261 has been marked as a duplicate of this bug. ***
*** Bug 424504 has been marked as a duplicate of this bug. ***
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
*** Bug 427441 has been marked as a duplicate of this bug. ***
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.
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"
*** Bug 441175 has been marked as a duplicate of this bug. ***
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.
(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.
(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.
(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.
(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.
*** Bug 338501 has been marked as a duplicate of this bug. ***
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.
(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".
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/116
(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.
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)
*** Bug 393273 has been marked as a duplicate of this bug. ***
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreenlocker/-/merge_requests/126
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.
Created attachment 155925 [details] Shorten screen power off timeout when screen is locked
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.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/142
(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.
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.
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.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/173
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
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
(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?
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
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.
Okay, seems like this is working in my laptop as well (KDE Neon Plasma 6.0 Beta 2). I'll mark it as resolved.
(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.
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.