Lock immediately after auto login

I am using Gnome. I want to enable auto-login and immediate screen lock. I have tried creating a desktop file in autostart directory. But it fails saying ; “Your Keyring wasn’t unlocked when you logged in”

Is there any simple method?

What is the content of that file?
Have you tried this?

Thank you very much. I’ve followed your link and created a script here__

dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock

But after startup Gnome says:

Authentication Required
Login keyring wasn’t unlocked last time you logged in

Locking the desktop immediately after login seems rather weird - why not disable auto login?

Disabling auto login will remove issues relating to the keyring

1 Like

This is normal to happen of you have autologin enabled. Autologin can log you in, but without your password it cannot open your keyring.

I don’t need to open keyring. But I want that the script I’ve added in “autostart-scripts” should run at startup. If It asks for the password to unlock the keyring instead of locking the session, it is sad.

If you enabled autologin after was not set so, you need to reconfigure pam also to access your keyring.


Can that even be done? Without setting empty password?


There are easier ways to start programs on startup. Try a systemd service.