Using xscreensaver to lock the screen in Lubuntu

Recent versions of Lubuntu seem to have broken screen locking.

To get screen locking via xscreensaver do this:

# Install xscreensaver
sudo apt-get install xscreensaver

# Start xscreensaver when you log in
echo "xscreensaver -nosplash" >> ~/.config/lxsession/Lubuntu/autostart

# Edit the "screen lock" launcher
sudo leafpad /usr/share/applications/lubuntu-screenlock.desktop

Change lubuntu-screenlock.desktop to look like this:

[Desktop Entry]
Name=ScreenLock (xscreensaver)
Comment=Lock your screen
Exec=xscreensaver-command -lock

If you want a keyboard shortcut to lock the screen, add this entry (under another <keybind> tag) to ~/.config/openbox/lubuntu-rc.xml:

    <keybind key="C-A-l">
      <action name="Execute">
        <command>xscreensaver-command -lock</command>