Xfce Forum

Sub domains
 

You are not logged in.

#1 2025-03-26 15:49:14

Computerix
Member
Registered: 2025-03-26
Posts: 1
LinuxFirefox 136.0

How to lock the screen on session startup?

I want to lock the screen immediately on session startup.

The solution I currently have is a shell script which repeatedly executes "xfce4-screensaver-command -l" without delay
until this command is successful.
Using the session and startup settings dialog, I've registered that shell script as "autostart application".

This basically works (the desktop is locked sooner or later) but has several problems:

* It is obviously insecure, because the desktop is visible (and seems to react to keyboard and mouse)
for almost one second before the locker locks the screen.
I'd need a secure solution which does not have race conditions
and gurantees that the desktop is not visible and not accessible at startup
(i.e. the desktop initially starts with the screensaver or the lock password screen).

* The shell script performs several / many iterations until the screensaver daemon becomes accessible for xfce4-screensaver-command:
The first few attempts fail because xfce4-screensaver is not yet listening.

Hence, both xfce4-screensaver and xfce4-screensaver-command -l are obviously taking effect as expected, but way too late.


So how do I

* make sure xfce4-screensaver is started and ready to accept commands
(and block the rest of the session startup until it is really started)

* and make sure that xfce4-screensaver-command -l has locked the screen
(ideally without repeating it in a loop until xfce4-screensaver becomes accessible)

before my desktop becomes visible, before any applications are started
and before it is possible to access the desktop in any way
(i.e. before the desktop, the panels or any applications react to keyboard or mouse input)?

Or are there any options to the screensaver daemon, the session manager or the window manager to initially start up locked?

Offline

#2 2025-03-26 22:54:52

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,815
LinuxFirefox 136.0

Re: How to lock the screen on session startup?

Hello and welcome.

What you are describing here is a display manager like lightdm. Why don't you just use a display manager? The computer would start and present the user with a log in screen? Once logged in and with the screensaver enabled, you can set it to auto-lock after a specific period of inactive time.


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2025-03-27 12:18:43

eriefisher
Wanderer
From: ON, Canada
Registered: 2008-10-25
Posts: 672
LinuxFirefox 136.0

Re: How to lock the screen on session startup?

To add to ToZ's suggestion with lightdm I would use

dm-tool lock

. It does not rely on Xfce4 so should be able to start at any time through session startup.


I AM CANADIAN!
Siduction
Debian Sid
Xfce 4.20 with Wayland/Labwc

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.012 seconds, 7 queries executed - Memory usage: 528.9 KiB (Peak: 530.18 KiB) ]