Ubuntu – How to lock the screen after resuming from hibernation

12.04hibernatelock-screen

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?

Best Answer

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.