How to lock screen via command line?

Asked by Aibara Iduas on 2014-07-02

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:
Aibara Iduas
Solved:
2014-07-08
Last query:
2014-07-08
Last reply:
2014-07-02
Thomas Kr├╝ger (thkrueger) said : #1

gnome-screensaver-command -l

Aibara Iduas (aibaraiduas) 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."

Aibara Iduas (aibaraiduas) 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.

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

Aibara Iduas (aibaraiduas) 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.

Aibara Iduas (aibaraiduas) 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

Aibara Iduas (aibaraiduas) said : #8

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