Reading time: < 1 min.
If you’ve ever used Windows, you already know their famous lock screen, found in almost all versions of the OS. Whenever you’re leaving your computer for longer than a couple of minutes, it might be worth it to protect it from anyone who might access it while you’re gone. On Windows, you can easily do that with a simple combination of Windows+L.
However, here we’re talking not about Windows, but about Raspberry Pi. If you’re using the command line mode and are not logged in, anyone who has access to it needs to log in.
But what about the Desktop mode? It would be nice if the screen locked by itself whenever you leave it open without input. This is especially important when using Pi as a server in Desktop mode, which makes it easier to control.
The “screensaver” isn’t installed by default, but there is a lock screen – however, you won’t find it in the menu. What you can do is add a handy icon by editing the file that controls your menu and toolbar.
Open the terminal window and type:
sudo nano /etc/xdg/lxpanel/LXDE-pi/panels/panel
Scroll down until you find the section starting with:
Plugin {
type=menu
Find the bottom of this section and paste in the following code:
item {
name=Lock…
image=gnome-lockscreen
action=/usr/bin/dm-tool lock
}
It should now look like this:
Save the file using the key combination ctrl+x, and press “y” to confirm your choice. Finally, press Enter.
After rebooting your Raspberry, you will find the “Lock” option in your menu, looking like this:
Now, whenever you move away from your Raspberry Pi, you can simply press Lock and nobody will be able to gain access to your personal files.
In order to get back into the desktop, simply put in your password.
*In the old Raspbian versions, you need to find the config file at
~/.config/lxpanel/LXDE-pi/panels/panel instead
How useful was this post?
Click on a star to rate it!
Average rating 5 / 5. Vote count: 1
No votes so far! Be the first to rate this post.
One Response
Useful, thanks!
Wondering if there was any simple way to add a short-cut keystroke for this? One that shows up on the menu itself (eg how ctrl-c is displayed next to Copy on most Edit menus)