Registered Member
|
In powerdevil or system settings advanced power management there is option to lock screen on resume this is ticked but only mode of suspend which I have seen lock is when i shut lid and configured it to suspend to RAM.
Besides this all other modes goes back main screen this is great until the day you decide you wish to have it locked I been fiddling at first I thought it was /etc/acpi/sleep.d etc.. but kde 4.2 uses pm-tools so here is a quick hack to make it lock screen on any mode of suspend At the bottom of /etc/pm/sleep.d/action_wpa add: /home/YOUR_USERNAME/scripts/disable-screen.sh tail -4 /etc/pm/sleep.d/action_wpa wpa_cli -i "${IFACE}" "${COMMAND}" done /home/USERNAME/scripts/disable-screen.sh Put below content starting with bin sh line as file line of script chmod to 755 ~/scripts# cat disable-screen.sh #!/bin/sh user=`env|grep HOME|awk -F"/" '{print $NF}'` su - $user -c "export DISPLAY=:0.0;qdbus org.kde.screensaver /ScreenSaver Lock ; xset dpms force off" ##### so long as the path is corret and action_wpa can see this script and it is exectuable upon next resume after a suspend you will need a password. |
Administrator
|
Warning to all users who try the above workaround:
It introduces a root level exploit to your system as the script /home/$USER/scripts/disable-screen.sh will be run by the suspend system as root. This script will be editable by users, and therefore represents a security vulnerability.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
ok.. I also found the $user does not work - shame so if it is only your Desktop i.e. not shared with other users.. so the fix which leaves no issues as explained in the above post is:;.. sudo vi /etc/pm/sleep.d/action_wpa su - YOUR_USERNAME -c "export DISPLAY=:0.0;qdbus org.kde.screensaver /ScreenSaver Lock ; xset dpms force off" |
Registered Member
|
I have tested below with different users and it seems to be working so it locks screen per user..
(There maybe many easier ways of finding current user logged into X - you could use either below..) cat /etc/pm/sleep.d/action_wpa |tail -3 user=`who -s|awk '{print $1" "$2}'|grep ":0"|awk '{print $1}'` #user=`ps aux|grep startkde|grep "/bin/sh"|awk '{print $1}'` su - $user -c "export DISPLAY=:0.0;qdbus org.kde.screensaver /ScreenSaver Lock ; xset dpms force off" |
Registered Member
|
Its a workaround/patch, not an idea.
It should be in either tips or bugs areas. |
Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]