Using xscreensaver to lock the screen in Lubuntu

March 26, 2014 [Lubuntu, Tech]

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)
Name[zh_TW]=鎖住螢幕
Comment=Lock your screen
Icon=system-lock-screen
Exec=xscreensaver-command -lock
NoDisplay=true

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>
      </action>
    </keybind>