Friday, April 29, 2011

Lock input without a screen saver in Linux

We came across this problem in the office today. How do we lock the input devices on a Linux machine (we were using Ubuntu 11.04) and keep a the current applications showing and updating? The solution we ended up with was to use xlock.

First you'll need to install xlock:
sudo apt-get install xlockmore
Then run xlock from a terminal with the following options:
xlock -mode blank -geometry 0x0 -timeout 2

The xlock command locks keyboard and mouse input, the flags do the following:
-mode blank displays a blank box in the top left corner of your monitor.
-geometry 0x0 makes the size of the blank box 0x0 pixels.
-timeout 2 sets the timeout (in seconds) for the password prompt if anyone hits a key.

Update 2011-05-02: A second (better) solution

First you'll need to install xtrlock:
sudo apt-get install xtrlock
Then run xtrlock from a terminal:

This will start xtrlock and lock the screen. To unlock the screen type your password and hit enter.