In https://bugs.launchpad.net/bugs/509411 I had the problem, that locking the screen would just not work any more. It turned out that gnome-screensaver must be perpetualy runnung in the background in order to be able to lock the screen.
Also this would affect the computer not locking the screen when suspending.
It might be that Gnome/Ubuntu are user-friendly, however the bloat is starting to annoy me. Why do I need to be running 214 processes, when the only thing that is actually being used is firefox and a terminal? Why do I need a process (gnome-screensaver) that is using up CPU cycles and virtual memory, when it’s actually never doing anything useful?
Thus I purged gnome-screensaver (8MB) and installed i3lock.
There are three things missing:
1) Make the laptop lock the screen when suspending:
$ cat /etc/pm/sleep.d/01_screenlock
# 01_screenlock: lock screen at suspend with i3lock
# based on http://bbs.archlinux.org/viewtopic.php?id=68158
IS_ACTIVE="$( pidof i3lock )"
# skip if i3lock is allready running
if [ ! "$IS_ACTIVE" ]; then
su - $USER -c "/bin/sh -c 'DISPLAY=$DISPLAY /usr/bin/i3lock'" &
case $1 in
# not required.
# not required.
*) exit $NA
2) Add it to the panel:
$ cat ~/.gnome2/panel2.d/default/launchers/i3lock.desktop
Name=Lock the Screen
3) integrate it into package management, so that I don’t accidentaly remove packages on which the screen locking depends:
$ cat control
Maintainer: Tomas Pospisek
Depends: i3lock, pm-utils, gnome-icon-theme
Files: 01_screenlock /etc/pm/sleep.d/01_screenlock
Description: lock screen on suspend/hybernate
$ equivs-build control
$ sudo dpkg -i lock-screen_1.0_all.deb
Of course, it's a hack. However it works and is easy to adapt. Let me know at tpo at sourcepole.ch in case you get to make it more generic.
That's it. Saved runtime bloat. Saved disk space (i3lock is 60K large).