In the Part 10 of the FreeBSD Desktop series I would like to describe key components of self made custom desktop environment such as:
- Window Manager
- Status Bar
- Task Bar
- Wallpaper Handling
- Application Launcher
- Keyboard/Mouse Shortcuts
- Locking Solution
- Blue Light Spectrum Suppress
Today we will focus on the sixth part – the Locking Solution. In the next series each of these components configuration would also be described along with eventual needed scripts.
You may also check earlier/other articles of the FreeBSD Desktop series:
- FreeBSD Desktop – Part 1 – Simplified Boot
- FreeBSD Desktop – Part 2 – Install
- FreeBSD Desktop – Part 3 – X11 Window System
- FreeBSD Desktop – Part 4 – Key Components – Window Manager
- FreeBSD Desktop – Part 5 – Key Components – Status Bar
- FreeBSD Desktop – Part 6 – Key Components – Task Bar
- FreeBSD Desktop – Part 7 – Key Components – Wallpaper Handling
- FreeBSD Desktop – Part 8 – Key Components – Application Launcher
- FreeBSD Desktop – Part 9 – Key Components – Keyboard/Mouse Shortcuts
- FreeBSD Desktop – Part 10 – Key Components – Locking Solution
- FreeBSD Desktop – Part 11 – Key Components – Blue Light Spectrum Suppress
- FreeBSD Desktop – Part 12 – Configuration – Openbox
- FreeBSD Desktop – Part 13 – Configuration – Dzen2
- FreeBSD Desktop – Part 14 – Configuration – Tint2
While screen locking feature is obvious for popular operating systems like Mac OS X (macOS) and Windows (or complete desktop environments such as KDE Plasma) its not when you build your desktop environment from the ground up. Similarly like in Part 9 about Keyboard/Mouse Shortcuts I will describe what light solutions will work here instead of focusing on all available solutions and choosing the best ones from them.
The tools we will embrace in this process are:
mate-screensaverxlockxautolock
The roles of mate-screensaver and xlock are redundant but we will keep xlock as fallback when mate-screensaver will fail for some reason. For example after upgrade some library may not be available (or will be present but in different version or filename) so mate-screensaver will fail and then xlock will take the role to securely lock the screen.
The xautolock will be used to automatically lock the screen (invoke mate-screensaver or xlock command) after defined period of inactivity time, for example when You would forgot to lock the screen and left the laptop ‘open’ to the World. 🙂
mate-screensaver
From all the nice looking solutions providing screen lock on the X11 I found mate-screensaver the best choice for this task. By default it does not display any fancy screensaver, just plain old blank screen, which is good for laptops, saves battery time.

The mate-screensaver has to be started and run in the background with, well mate-screensaver command – placed somewhere in the ~/.xinitrc or ~/.xsession file. Then we would be able to invoke mate-screensaver-command --lock command to make the actual screen lock.
xlock
When mate-screensaver will not be available or functional we will use xlock as failover solution.
Its not very pretty and does not support FreeType fonts, but with clean or fixed font face its not that bad either, as they are quite nice and usable bitmap fonts.
The xlock tool appearance can be configured by specifying arguments. Below you will find example configuration with gray background and clean bitmap font.
% xlock \
-mode blank \
-planfontset '-*-clean-*-*-*-*-*-*-*-*-*-*-iso8859-2' \
-fontset '-*-clean-*-*-*-*-*-*-*-*-*-*-iso8859-2' \
-username 'USERNAME: ' \
-password 'PASSWORD: ' \
-background gray30 \
-dpmsoff 1 \
-message ' ' \
-info ' '
Here is how it looks after configuration.

xautolock
We have addressed the on demand screen locking case but now we also need to make sure, that our screen will automatically lock after some period of time while we are away from the computer. Small utility called xautolock does exactly that and does it very efficiently.
Example invocation is presented below.
% xautolock \
-time 1 \
-locker \
~/bin/example-lock-handler.sh \
-resetsaver
The xautolock also has to be started and run in the background using the ~/.xinitrc or ~/.xsession file.
Pingback: FreeBSD Desktop – Part 11 – Key Components – Blue Light Spectrum Suppress | vermaden
Pingback: FreeBSD Desktop – Part 12 – Configuration – Openbox | vermaden
Pingback: FreeBSD Desktop – Part 13 – Configuration – Dzen2 | vermaden
Pingback: FreeBSD desktop (10) | 0ddn1x: tricks with *nix
Pingback: FreeBSD Desktop – Part 14 – Configuration – Tint2 | vermaden
Pingback: FreeBSD Desktop – Part 9 – Key Components – Keyboard/Mouse Shortcuts | vermaden
Pingback: FreeBSD Desktop – Part 7 – Key Components – Wallpaper Handling | vermaden
Pingback: FreeBSD Desktop – Part 8 – Key Components – Application Launcher | vermaden
Pingback: FreeBSD Desktop – Part 6 – Key Components – Task Bar | vermaden
Pingback: FreeBSD Desktop – Part 5 – Key Components – Status Bar | vermaden
Pingback: FreeBSD Desktop – Part 4 – Key Components – Window Manager | vermaden
Pingback: FreeBSD Desktop – Part 15 – Configuration – Fonts & Frameworks | vermaden
Pingback: FreeBSD Desktop – Part 1 – Simplified Boot | vermaden
Pingback: FreeBSD Desktop – Part 2 – Install | vermaden
Pingback: FreeBSD Desktop – Part 3 – X11 Window System | vermaden