This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Turn off monitor after locking screen

Tags: None
(comma "," separated)
User avatar
Rewarp
Registered Member
Posts
70
Karma
0
OS
After invoking the lockscreen command, I would like KDE to switch off the screen 20 seconds after locking. I can't seem to find the command anywhere to chain these two options together.

Anyone out there know a solution?
luebking
Karma
0
I'm not entirely sure what/how you seek to do, but

Code: Select all
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


will lock the screen, sleep 20 seconds and turn off the screen if the locker is (still or again) active.
You can eg. bind that to a hotkey or whatever.
User avatar
Rewarp
Registered Member
Posts
70
Karma
0
OS
Thanks!

I want to save power since locking the screen means I won't be interacting with the computer anyway. However, if I am compiling software for instance, I would prefer the screen be turned off rather than shutting down the computer.
luebking
Karma
0
=)
I meant whether you were trying to write some plasmoid (python, c++) or patch ksmserver or just wanted to know some bashlet.

This, or rather maybe enabling and lowering dpms timeouts (so the screen turns off after 20s of inactivity while the locker is up) might be a useful feature in the locker code (when the locker is explicitly invoked) - considered to file a bugwish?
User avatar
Rewarp
Registered Member
Posts
70
Karma
0
OS
Sorry, I don't know how to write code for plasmoids. :'( I was also checking to see if I missed any features in System Settings.

I would be pleased to file a wishlist bug for the screenlocker. Which component of KDE would be the most appropriate?

Update: Wishlist "bug" filed
https://bugs.kde.org/show_bug.cgi?id=348529

Last edited by Rewarp on Mon Jun 01, 2015 2:25 am, edited 1 time in total.
User avatar
Rewarp
Registered Member
Posts
70
Karma
0
OS
By the way, this only works during the initiation of the lock screen. How do you get it to loop back into turning off the screen again if the keyboard is disturbed during the screen lock?

/cats :*
luebking
Karma
0
Quick hack

Code: Select all
qdbus org.freedesktop.ScreenSaver /org/freedesktop/ScreenSaver Lock
xset dpms 20 24 30 # standby suspend off
while [ "`qdbus org.freedesktop.ScreenSaver /org/freedesktop/ScreenSaver GetActive`" = "true" ]; do
   sleep 30
fi
xset dpms 300 360 400 # standby suspend off


to be correct, it should query "xset -q" for the present dpms settings and restore them afterwards
User avatar
Rewarp
Registered Member
Posts
70
Karma
0
OS
I am guessing there is something missing, because the revised code does not restore my dpms settings, but remains 20, 24, 30.

It does restore dpms when I run this line after unlocking.

xset dpms 5520 8280 11040 # extra long because screen times out during video streams, a hacky solution on my part)
luebking
Karma
0
Who wrote that? I could swear I had a "done" there ;-P
The below should safe your previous settings.

Code: Select all
DPMS_STATE="`xset -q | grep "DPMS is"`"
DPMS_TIMES="`xset -q | sed '/  Standby/ !d; s/[^0-9]\+/ /g' `"
qdbus org.freedesktop.ScreenSaver /org/freedesktop/ScreenSaver Lock
xset dpms 20 24 30 # standby suspend off
while [ "`qdbus org.freedesktop.ScreenSaver /org/freedesktop/ScreenSaver GetActive`" = "true" ]; do
   sleep 30
done # this line was the bug
xset dpms $DPMS_TIMES
if [[ "$DPMS_STATE" == *Disabled* ]]; then
   xset -dpms # turn off if it was
fi
User avatar
Rewarp
Registered Member
Posts
70
Karma
0
OS
;D That's so awesome!

It's practically ready for deployment now.

I really should get around to reading about bash scripting and regular expressions. That Packt ebook is gathering digital dust somewhere.
User avatar
Rewarp
Registered Member
Posts
70
Karma
0
OS
Kai Uwe Broulik is adding it to his todo list.

https://bugs.kde.org/show_bug.cgi?id=348529#c4

Have I mentioned before how much I love the KDE community? :)


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]