Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

408. Screen lock

The screen lock is Plasma’s: KWin’s screen locker, kscreenlocker, covers every output and asks for the account’s password before the session shows again. This page covers when it locks by itself, the PAM stacks it checks a password against, locking by hand, and what to do when the lock screen will not unlock. Locking, idle and power together are described in Locking, idle and power; this page gives the procedures.

Installation

Port Provides
kscreenlocker The locker KWin runs, its greeter kscreenlocker_greet, the Screen Locking page of System Settings, and the PAM stacks kde and kde-fingerprint
kwin Holds the locked state: while the session is locked KWin shows only the greeter, and a greeter that dies leaves the screen locked rather than open
powerdevil The idle timers that dim and blank the screen, and the lock before a suspend
elogind PrepareForSleep, on which the locker locks before the machine sleeps, and loginctl lock-session
pam unix_chkpwd, the setuid helper that reads /etc/shadow for a process that is not root
fprintd The fingerprint service the kde-fingerprint stack asks; see Fingerprints, FIDO keys and smart cards

The locker runs inside the session and is not a service. The live medium and an installed system lock alike, except that neither the live medium nor a virtual machine locks on a timer.

Configuration

When the screen locks

KDOS’s defaults, from fs/usr/share/kdos/xdg/kscreenlockerrc:

[Daemon]
Autolock=true
Timeout=10
LockGrace=5
LockOnResume=true

[Greeter][LnF][General]
alwaysShowClock=true
showMediaControls=true

[Greeter][Wallpaper][org.kde.image][General]
Image=file:///usr/share/wallpapers/KDOS-Bone/

fs/usr/share/kdos/xdg/kscreenlockerrc, lines 23–34

So the screen locks after 10 minutes without input, a key or a move within 5 seconds of the lock unlocks with no password, and the machine always resumes locked. The screen itself dims at 5 minutes and turns off at 15 on mains power, which is PowerDevil’s, from fs/usr/share/kdos/xdg/powerdevilrc:

[AC][Display]
DimDisplayIdleTimeoutSec=300
TurnOffDisplayIdleTimeoutSec=900

fs/usr/share/kdos/xdg/powerdevilrc, lines 17–19

In a virtual machine and on the live medium the screen does not lock on a timer. The session puts an extra settings directory first in XDG_CONFIG_DIRS there (/usr/share/kdos/xdg-vm in a virtual machine, /usr/share/kdos/xdg-live on the live medium), for two reasons:

Meta+L and the lock on resume still lock there, and kdos unlocks them. The timeout of 0 is what makes System Settings → Screen Locking read “Never”, rather than the 10 minutes it would otherwise inherit. From fs/usr/share/kdos/xdg-vm/kscreenlockerrc:

[Daemon]
Autolock=false
Timeout=0

fs/usr/share/kdos/xdg-vm/kscreenlockerrc, lines 20–22

A person’s choices on System Settings → Screen Locking are saved in ~/.config/kscreenlockerrc and outrank all of these.

The PAM stacks

The greeter checks a password against /etc/pam.d/kde and, in parallel, a fingerprint against /etc/pam.d/kde-fingerprint, from ports/core/kde/kscreenlocker/build.sh:

install -vdm755 "$PKG/etc/pam.d"
cat > "$PKG/etc/pam.d/kde" << "EOF_PAM"
# Begin /etc/pam.d/kde
auth      include    system-auth
account   include    system-account
# End /etc/pam.d/kde
EOF_PAM

cat > "$PKG/etc/pam.d/kde-fingerprint" << "EOF_PAM"
# Begin /etc/pam.d/kde-fingerprint
auth      required   pam_fprintd.so
account   include    system-account
# End /etc/pam.d/kde-fingerprint
EOF_PAM
chmod 644 "$PKG/etc/pam.d/kde" "$PKG/etc/pam.d/kde-fingerprint"

ports/core/kde/kscreenlocker/build.sh, lines 28–42

system-auth runs pam_unix, which, in a process that is not root, asks unix_chkpwd to check the password against /etc/shadow. Smart card, face and FIDO unlocking are compiled out.

An autologin that starts locked

On the encrypted single-account machine whose install asked for autologin, the session starts behind the lock screen: the autologin’s own configuration directory carries LockOnStart=true. See Login and autologin.

Usage

Locking by hand

Unlocking

Type the account’s password and press Enter, or touch an enrolled finger. The greeter shows the clock and the media controls; Switch User goes back to SDDM’s greeter for another account while this session stays locked.

Changing when the screen locks

  1. System Settings → Screen Locking.
  2. Set Lock screen automatically to the minutes you want, or turn it off; set Delay before password required for the grace; turn Lock after waking from sleep on or off.
  3. Apply. It applies at once.

Keeping the screen on for a while

The battery and brightness applet in the system tray has Manually block sleep and screen locking, which holds both until it is turned off. A video player or a presentation does the same while it plays, through the inhibition interface; the applet lists who holds one.

Tips

Troubleshooting

The correct password is refused. Log in on tty2 with the same password. A refusal there too means the password is not what you think. If tty2 accepts it, check the helper:

ls -l /usr/sbin/unix_chkpwd     # -rwsr-xr-x root: setuid
sudo grep -E 'kscreenlocker|unix_chkpwd' /var/log/messages | tail

Without the setuid bit no process but root can check a password, and every unlock fails.

The lock screen will not go away. Unlock it from another console:

  1. Ctrl+Alt+F2, log in as the same user.
  2. loginctl list-sessions to find the locked graphical session’s id, then loginctl unlock-session <id>.
  3. Ctrl+Alt+F1.

The screen does not lock after the timeout. Something holds an inhibition: open the battery and brightness applet to see which application. A virtual machine and the live medium do not lock on a timer by design; echo "$XDG_CONFIG_DIRS" starts with an overlay there.

The machine resumes unlocked. LockOnResume was turned off on the Screen Locking page; turn Lock after waking from sleep back on.

Known gaps

See also