I like to set up my Ubuntu workstation to automatically log into my account and then immediately lock the screen. This allows all my processes to start up and also allows me to VNC into the main console session via the Remote Desktop (vino) server. There are a few ways to set this up:
First, set up auto-login:
System > Administration > Login Window > Security tab
Check ‘Enable Automatic Login’ and choose your username. Click ‘Close’.
As for locking the screen after login, you can try adding the following command to System > Preferences > Sessions:
gnome-screensaver-command --lock
or
xdg-screensaver lock
I found that these commands worked for me when logging in and out of the box. However, I found that they did not work for me when I rebooted my workstation. If any of the other commands listed Sessions utilize gnome-keyring, such as ‘mail-notification’, the gnome-keyring password prompt seems to keep the screen from being locked. To work around this, I created a script called ‘lockstartup’. This script does the following:
1. Pauses for 10 seconds (a step I found necessary in order to get the script to work correctly)
2. Locks the screen
3. Pauses for another 10 seconds (again, a step I found necessary)
4. Starts any applications that use gnome-keyring
Here is what my script looks like:
#!/bin/sh
sleep 10
xdg-screensaver lock
sleep 10
mail-notification
After you save the script, make it executable:$ chmod +x lockstartup
And then add it to System > Preferences > Sessions. If you reboot, you should be automatically logged in and then see the screen lock. Once you unlock the screen you should be presented with the gnome-keyring password prompt.
I am using this on Ubuntu 8.10 Intrepid Ibex. I have not tested this on any other releases.
Comments
Hi Marius. Unfortunately, gnome-keyring does not unlock if you auto-login in. It only automatically unlocks if you enter your password manually to log into the workstation.
The idea has been submitted to Ubuntu brainstorm, here is the link:
http://brainstorm.ubuntu.com/idea/11882/
There is already an idea for this:
http://brainstorm.ubuntu.com/idea/9187/
Unfortunately it has -21 votes, not sure why people don’t like it.
I see, I did not realize that. Thanks for clarifying.
There seem to be many duplicate ideas for this
Lucas, I believe the difference is that xdg-screensaver is a standardized way to lock any compliant screensaver application, such as gnome-screensaver, xscreensaver, kscreensaver, etc. (Someone please correct me if I’m wrong).
Two questions:
1a) Why can’t you trigger the screen lock mechanism built in Ubuntu?
1b) What is the name of the utility of the screen lock mechanism built in Ubuntu?
2) I’m using the latest Ubuntu 9.04, and I don’t see “System->Preferences->Sessions” at all. Has it been renamed?
My server in the office that auto POWERS ON at 7AM and auto logs-in (so no one needs to enter the password).
I add this in Startup Applications.
gnome-screensaver-command –lock
I’m using Ubuntu Lucid Lynx 10.04 LTS.
Thanks. Works like a charm.









Auto-login and then lock is a really neat idea. Never thought about it.
Why is gnome-keyring prompting you for a password? You can have the keyring automatically unlocked when you login. Or you prefer not to do that?
I think this automatic login and then automatic screen lock should be supported by Gnome/Ubuntu. Why don’t you add a feature request, or submit an idea to Ubuntu brainstorm?