HomeHome ArchiveArchive

removing gnome-screensaver

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
#!/bin/bash
#
# 01_screenlock: lock screen at suspend with i3lock
# based on http://bbs.archlinux.org/viewtopic.php?id=68158
#

USER=henry
DISPLAY=:0.0
IS_ACTIVE="$( pidof i3lock )"

lock_screen() {
  # skip if i3lock is allready running
  if [ ! "$IS_ACTIVE" ]; then
       su - $USER -c "/bin/sh -c 'DISPLAY=$DISPLAY /usr/bin/i3lock'" &
  fi
}

case $1 in
   hibernate)
       lock_screen
       ;;
   suspend)
       lock_screen
       ;;
   thaw)
       # not required.
       ;;
   resume)
       # not required.
       ;;
   *) exit $NA
       ;;
esac

​2) Add it to the panel:

$ cat ~/.gnome2/panel2.d/default/launchers/i3lock.desktop
#!/usr/bin/env xdg-open

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Icon=/usr/share/icons/gnome/scalable/actions/gnome-lockscreen.svg
Name=Lock the Screen
Exec=i3lock

​3) integrate it into package management, so that I don’t accidentaly remove packages on which the screen locking depends:

$ cat control
Section: misc
Priority: optional
Standards-Version: 3.6.2

Package: lock-screen
Maintainer: Tomas Pospisek 
Depends: i3lock, pm-utils, gnome-icon-theme
Files: 01_screenlock /etc/pm/sleep.d/01_screenlock
 i3lock.desktop /home/henry/.gnome2/panel2.d/default/launchers/i3lock.desktop
Description: lock screen on suspend/hybernate
 bla
$ 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).