Cart 0

How to lock your Raspberry Pi Screen

Many of you will be familiar with the Windows screensaver/lock screen.  If you are going to leave your PC alone for any amount of time where others may have access to it (like in a busy office) then it is advisable to lock it every time you walk away from it using the Win+L key combinations.

But we are talking about the Raspberry Pi here.  If you are running it headerless or in command line mode and you are not logged in, then anyone who has access to it will need to log in (you have changed the default password, haven’t you?).

But what if you have a Raspberry Pi in Desktop mode?  The same applies to a Raspberry Pi as it does to a PC; you should lock the screen if you walk away from it.  This is especially important if you are using a Pi as a server and have Desktop mode running to help with management of a service.

Banking on your Pi

A ‘screensaver’ is not installed by default, but a lock screen is; it’s has just not been put onto the menu.  You can do that by editing a file that defines how your menus and toolbar appears.

Open a terminal window, and type in*:

sudo nano /etc/xdg/lxpanel/LXDE-pi/panels/panel

Editing the menus using nano

Scroll down (using the cursor keys) to the section that starts:

Plugin {

  type=menu


Finding the right part of the configuration file

Move to the end if this section, and type in (or copy/paste) the following:

    item {
      name=Lock…
      image=gnome-lockscreen
      action=/usr/bin/dm-tool lock
    }

The file should look like this:


 Adding the lock menu

Save the file by typing typing Ctrl+x (the Ctrl key, with x), then ‘y’ to the prompt to save, and the Enter key.

After your next reboot, you will now see a new item at the bottom of your menu:


The Lock… menu

Now, when you are going to be away from your Raspberry Pi, all you need to do to secure it is to click on the Lock… menu and the screen will be locked:


The Lock… screen

Just type in your password, and your Pi and you can resume from where you left off.

* On older versions of Raspbian, you may find the configuration file in ~/.config/lxpanel/LXDE-pi/panels/panel instead.



Older Post

Related Posts

Using IFTTT with the Raspberry Pi
Using IFTTT with the Raspberry Pi
IFTTT (If This Then That) is a free IoT service that allows you to send a trigger from one device/thing, and allow th...
Read More
Auto-Starting Programs on the Raspberry Pi
Auto-Starting Programs on the Raspberry Pi
There are multiple ways of auto-starting programs on the Raspberry Pi when it boots or you log in.  There’s ‘cron’, ‘...
Read More
Securely Logging into a Raspberry Pi without a Password
Securely Logging into a Raspberry Pi without a Password
We’re always being told to choose a long, hard to guess password for all our accounts, so how can we log into a Raspb...
Read More