How can I lock my screen in Gnome 3 without GDM?

After some research, I think I've got enough information to post an answer to my own question.

In Gnome Shell 3.6 and earlier, the old gnome-screensaver program was present, and if GDM was not running, gnome-screensaver would be invoked - allowing you to lock the screen.

Starting in Gnome Shell 3.8 (included in Fedora 19), gnome-screensaver support has been dropped completely. This was done for three reasons: reduced code complexity coupled with the fact that the screensaver is seen as an unneeded feature, and the fact that the eventual move to Wayland will require screensaver, locking, etc. support to be in the compositor.

So the only Gnome-integrated way of locking the screen is to have GDM running, which will respond to a dbus message telling it to lock the screen. Other display managers (such as XDM) have not been designed to respond to this dbus message, and so the screen cannot be locked.


From this link:

In old versions of gnome the command gnome-screensaver-command -l would lock your screen. As gnome-screensaver is no more in gnome 3.8 you now have to send a dbus call. I think this is then handled by GDM.

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

Super+L works in Fedora 24 which is running Gnome 3.20


This works for me in Gnome 3.14. Standard installation, no customization.

gnome-screensaver-command --lock