lock screen before suspend with power button
I am using Slackware 12.0 with KDE on a HP zv5000 laptop and a 2.6.22 kernel. I use kpowersave for suspending and hibernating. Everything works fine, and I have it configured to lock the screen before either action. I would like to be able to suspend (to RAM) when I press the power button, so I edited "/etc/acpi/acpi_handler.sh" to suspend instead of shutdown the system. This also works fine, but I do not know how to get it to lock the screen first. I have tried adding "/usr/bin/kdesktop_lock --forcelock" to acpi_handler.sh before I call suspend, but it doesn't work (the command does work on its own, it just doesn't seem to have any effect in the script.
Does anyone know how I can do this? Thanks, Brian |
Moved to Slackware at posters request.
|
Code:
USER="guo" |
zhoun,
Thanks for the suggestion. Unfortunately it does not help and the behavior is the same. Brian |
Just a wild guess: maybe that kdesktop_lock isn't quick enough to lock the screen before actual suspend to RAM happens.
|
Quote:
Brian |
BTW, This languished for a week in another LQ forum with no response. I get it moved to the Slackware forum this morning and I've got two responses already. Thanks, Slackers for a great forum.
Brian |
I bet kdesktop_lock needs to find the environment variables of a corresponding running KDE session for it to work, and they won't be available when it's called from acpid, which is launched at boot. In my system I suspend to ram by closing the laptop, so I have created a shell script that stops a couple of things, calls s2ram and then restores the things I stopped, and I have associated the LID button event to call that script. It's similar to what you do. To lock the screen before suspending, I do it by hand. It's very easy and not annoying if you set up a keyboard shortcut to do so, like I did with Ctrl+Alt+L. So when I want to suspend to RAM I press Ctrl+Alt+L and close the laptop. Piece of cake.
|
Please try this again.
Code:
USER="guo" I copy the code from my acpi scripts. It worked fine for me with all thinkpad Fn functions. |
zhoun,
I added the additional line, still no dice. rg3, Which environment variables were you referring to? Brian |
My /etc/acpi/acpi_handler.sh, just for reference.
I have no idea why it not work for you. Code:
#!/bin/sh |
Or you can monitor the acpi log file:
/var/log/acpid If error happens, it will be logged in this file. |
Thank you all, especially zhoun. I have a solution. This is the relevant section of my acpi_handler.sh:
Code:
export DISPLAY=":0" 1. I do not need the "export XAUTHORITY" line because I do "xhost +localhost". If I didn't, then the "export XAUTHORITY" line is necessary 2. The ampersand after the kdesktop_lock command is necessary or it will not suspend until I unlocked the display 3. The sleep 3 line is necessary or it will not lock until after the system is resumed, allowing a brief glimpse of the screen display 4. If you do not have the root password, then the "su..." line from zhoun's post is necessary. Thanks again for all the help. Brian |
You got it! :)
Your comments is clear and will help other people. |
All times are GMT -5. The time now is 10:36 PM. |