How to lock screen via command line?

Asked by Cavia Porcellus

I want to know how to bring up the lock screen via the command line. Using "dm-tool lock" comes close, but it actually does the same thing as "dm-tool switch-to-greeter" (lets you log in as a guest, certain functions, like playing music, cease). Maybe this is a bug and dm-tool lock should actually bring up the lock screen?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu lightdm Edit question
Assignee:
No assignee Edit question
Solved by:
Cavia Porcellus
Solved:
Last query:
Last reply:
Revision history for this message
Thomas Krüger (thkrueger) said :
#1

gnome-screensaver-command -l

Revision history for this message
Cavia Porcellus (caviaporcellus) said :
#2

Sorry, I should have specified that I'm using Ubuntu 14.04. The gnome-screensaver method does not work (indeed, I don't even have gnome-screensaver installed, having replaced it with xscreensaver).

I'm looking to get Unity's lock screen, the same one you get by going to the cog/system menu at the top left of the Unity panel and then going to "Lock."

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#3
Revision history for this message
Cavia Porcellus (caviaporcellus) said :
#4

Thanks for the suggestion, but it just confirms that "gnome-screensaver-command -l" does not work in 14.04 and otherwise is an open question.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#5

Yes but there are other commands in the link too.....did you try those?

Revision history for this message
Cavia Porcellus (caviaporcellus) said :
#6

I have, and have the same issues as the person who asked that question. (Note that I commented on that very question; just figured someone here might have some special insight). Thanks for your help so far though.

Revision history for this message
Cavia Porcellus (caviaporcellus) said :
#7

I guess I'll file a bug report, since I think the command "dm-tool lock" should bring up the proper lock screen.
https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1338814

Revision history for this message
Cavia Porcellus (caviaporcellus) said :
#8

Ah, ok, got it:
dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock