Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ubuntu 14.04 introduces a new lockscreen that looks similar to the login screen.

New lockscreen

I am still able to lock the screen using the command gnome-screensaver-command --lock (as I always did before), which under 14.04 does lock the screen, but:

  • If you are running it from the desktop, it locks the screen using the new lockscreen.
  • If you are running it from a virtual console or via SSH, it locks the screen using the old lockscreen.

I've also tried using xdg-screensaver lock, but it works in the same way as gnome-screensaver-command --lock does (only uses the new lockscreen when it's ran from the desktop).

Running light-locker-command --lock didn't work, as light-locker is not installed.

I guess there must be some differences between running the same command from the desktop and running it via SSH/virtual console, but I was not able to find any difference in the environment variables.

So, my question is: How can I lock the screen using the new Unity lockscreen and not the old lockscreen from the command line?

This question is probably related as it asks for the new command that needs to be used, so here's another question: Why does running the same lock command give different results?

Note that gnome-screensaver is not being used anymore in 14.04, according to this bug report:

That's not really a gnome-screensaver bug, that component stopped being used in trusty.

share|improve this question
2  
I would like to know as well. Using dm-tool lock comes close: it locks the screen, but (unlike the default Unity lock screen) also allows you switch users. – Aibara Iduas Jun 30 '14 at 22:58
2  
dm-tool lock and dm-tool switch-to-greeter seem to be doing the same thing: take you back to the log in screen (greeter), which does look very similiar to the lockscreen. – Léo Lam Jul 2 '14 at 12:48
up vote 7 down vote accepted

I don't have gnome-screensaver installed, and the only command I can find that works is this:

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

share|improve this answer
4  
qdbus org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock – Aquarius Power Aug 2 '14 at 0:37
    
This used to work, but it seems not to work anymore in 15.10 :/ – Léo Lam Jan 16 at 13:18
    
@LéoLam Are you using a livecd image? I'm still using 14.04, but I did test both my command and Aquarius Power's in 15.10 and got them to work. However, I had to enable the lock screen to get it to work via this command gsettings set org.gnome.desktop.lockdown disable-lock-screen false – Aibara Iduas Jan 17 at 22:22
    
Nope, it's on a real Ubuntu install. gsettings get org.gnome.desktop.lockdown disable-lock-screen returns false. Now there's no output at all when running dbus-send. Maybe gnome-screensaver is needed for this to work? – Léo Lam Jan 18 at 18:09
    
I tested 15.10 without gnome-screensaver (though xscreensaver was installed instead) and it still worked fine. Not sure what the problem is... – Aibara Iduas Jan 19 at 6:37

I recently found out that xdg-screensaver lock works aswell and is quite a simple solution too!

share|improve this answer
    
It is mentioned in the OP that it does not work in all cases. Only when you're running it locally in a terminal from the GUI. – Léo Lam Jan 23 at 11:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.