How do I lock the screen after resuming from hibernation?
I've been able to successfully hibernate and resume my Ubuntu 12.04 Desktop PC using procedure that I've documented in this answer. However, I now have a problem that whenever the PC resumes, it does not locks the screen.
How can I lock the screen after the system resumes back from hibernation?
I have added an alias into ~/.bashrc
file
alias hibernate='sudo echo "Hibernating..."; gnome-screensaver-command -l; sudo pm-hibernate;'
So that it locks the screen before hibernating.
I've been able to workaround this issue, by using the following command
sudo pm-hibernate; gnome-screensaver-command -l
Do note that, you should run this as a normal user and not as root user for locking to work, because by default in Ubuntu, there is no password for the root user so after resume, lock-screen can be unlocked by simply shaking the mouse.
i have another workaround.
i copied this from /etc/acpi/sleep.sh
to /etc/acpi/hibernate.sh
just before pm-hibernate
if [ x$LOCK_SCREEN = xtrue ]; then
if pidof xscreensaver > /dev/null; then
for x in /tmp/.X11-unix/*; do
displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
getXuser;
if [ x"$XAUTHORITY" != x"" ]; then
export DISPLAY=":$displaynum"
. /usr/share/acpi-support/screenblank
fi
done
fi
fi
now i can hibernate with lock from power menu or a sleep button