How to : screen lock or screensaver for awesome window manager

This post gives you answer for 2 questions.

1. Screen lock in awesome window manager ?
2. Screensaver in awesome window manager ?

By default awesome window manager doesn’t provide any inbuilt support for locking the screen or screen saver. It can be achieved with any one of the following standalone apps and small modification to rc.lua.

1. slock –
2. xscreensaver
3. xtrlock

In this article I will demonstrate how to use xscreensaver with awesome to lock your screen. The steps for other tools should be almost same with very few small modification.

Installing xscreensaver. For Ubuntu:

sudo apt-get install xscreensaver

Editing the rc.lua

Add the following lines In your rc.lua file under “Standard program” section.

-- Standard program
awful.key({ }, "F12", function () awful.util.spawn("xscreensaver-command -lock") end),

In the above code “F12” is our short cut key, and “xscreensaver-command -lock” is the command to be executed when the key is pressed. I our case it should start the screen saver and lock the screen.

At the end of rc.lua file add the following lines to start the xscreensaver application, here -no-splash switch says not to show splash screen when starting xscreensaver.

awful.util.spawn_with_shell("xscreensaver -no-splash")

Now restart awesome window manager.


Open a command and use the below command to make suer the xscreensaver application is started by awesome.

$ ps -ef | grep xscreensaver
mohamed 2984 1 0 17:06 ? 00:00:00 xscreensaver -no-splash
mohamed 3857 3796 0 18:19 pts/4 00:00:00 grep --color=auto xscreensaver

From the above we can see the xscreensaver is running as intended.

Now press “F12” key in you keyboard, xscreensaver application should lock your screen. If you do any mouse or keyboard activity It will prompt you for password.

That’s it. done!. Leave you comment.

2 thoughts on “How to : screen lock or screensaver for awesome window manager

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s