How to wake from screensaver directly to the login screen in Ubuntu
(a.k.a. How to switch users without entering password, part II) (see part I)
I've got Ubuntu 9.10 with a user account for my wife, and one for myself. "Wake-from-screensaver" should result in "choose user" without having to enter any password. I know how to do that in Windows, but I'm not good with Linux (yet).
Part of this was answered in my earlier question which helped me get past the login screen without passwords (after booting, and after choosing "switch user"), but once the screensaver kicks in and I wake it up again, the system does not present the "choose user" screen. Instead, it either turns off the screensaver and presents the desktop of the most recent user, or (if the screensaver is set to lock the screen) prompt for the user's password (which can be handily surpassed by clicking the "switch user" button and choosing the same user again).
So, the login ("choose user") screen has been dealt with. How do I make the (any) screensaver return to the login screen at wake, rather than to the current user's desktop? Windows can do this, I'm sure Linux can too - but how?
Solution 1:
You're making a habit of weird tweaks, aren't you?
Anyway, this one is weird, but interesting. I'm sorry to say I don't have a complete solution, but I found a couple of interesting items that warrant a response. They may give you some ideas of where to go from here.
-
Gnome-Screensaver's FAQ indicates that the screensaver emits a DBus signal when the session's idle status changes:
Is there a way to perform actions when the screensaver activates or deactivates? Or when the session becomes idle?
One way is to watch for the D-Bus signals from gnome-screensaver. (...)
The FAQ provides an example dbus-monitor command:
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'"
Although I believe the interface and member details are outdated for Ubuntu 9.10; the proper values seem to be interface=org.freedesktop.ConsoleKit.Session and member=IdleHintChanged. (See the ConsoleKit documentation.)
When the screensaver lock is enabled, the IdleHintChanged signal is emitted after the password is entered successfully into the unlock dialogue.
-
The command gdmflexiserver -xnest can be used from the commandline to get back to the login screen. It works within your X session by itself, but you can use dbus-launch to execute it from, say, an SSH session:
DISPLAY=:0 dbus-launch gdmflexiserver -xnest
That "activates" the GDM login screen, without logging the current user session out, just like the "Switch User..." menu option does (at least as far as I can tell).
The trick will be to find some way to glue these two together. It seems to me that what you'd want to do is basically:
- Disable the screensaver's lock;
- Register a listener with DBus that listens for the IdleHintChanged signal on all sessions;
- Have the listener execute the gdmflexiserver command when it detects the signal.
Step 1 is needed so you don't get the password prompt. If step 2 works properly and step 3 kicks off, you'll get the login window anytime your system comes out of the screensaver. But step 2 is what I'm not sure how to do.
Solution 2:
I understand that this question is for years ago, but some users may be still searching for this.
One may prefer Ubuntu login screen to lock screen at wake (for example not to show even the wallpaper on an encrypted home), and this is possible in Ubuntu 12.10 and 13.04 (not sure about earlier versions).
So to do this, open Dconf Editor (pre-installed on Ubuntu 12.10+) and go to:
org > gnome > desktop > screensaver
Enter the command dbus-launch gdmflexiserver -xnest
for the variable embedded-keyboard-command. Then check embedded-keyboard-enabled for the same schema.