4

When I use Ubuntu 12.04, after I click the "Lock" button from status bar in desktop, it will show the locked screen. I use another computer to ssh to this locked computer. And use command

export DISPLAY=:0    
gnome-screensaver-command -d

to unlock the screen. It works well.

But now, I upgrade Ubuntu from 12.04 to 14.04. When I click the "Lock" button from status bar, it will show the new locked screen which looks like the unity-greeter. Then I use the same command as before:

export DISPLAY=:0    
gnome-screensaver-command -d

Nothing happens~ I can't unlock the screen by command.

It looks like a bug in Ubuntu. https://bugs.launchpad.net/ubuntu/+source/gnome-screensaver/+bug/1307163

But is there any workaround to solve this problem?

[update]

I found if we use lock screen command from ssh

export DISPLAY=:0
gnome-screensaver-command -l

it will show the gnome classic screensaver just like Ubuntu 12.04. And use command gnome-screensaver-command -d can unlock the screen.

So is there a way to switch to gnome classical screensaver when click the lock button in status bar?

PS, I have tried CompizConfig Settings Manager, there is not option about changing the lockscreen~~

0

3 Answers 3

0

A workaround would be to use an alternative screensaver, for example the classic linux xscreensaver. this can be deactivated from command line with

xscreensaver-command -deactivate
3
  • Actually I do not want to use other screensaver. Is there a way to use the gnome classical screensaver? When I use command gnome-screensaver-command -l via ssh, it will show the normal gnome classical screensaver. Also I can unlock it via gnome-screensaver-command -d. But when I press Lock button, it will show the Unity screensaver.
    – lee
    Commented Dec 22, 2016 at 2:46
  • in that case maybe this will help you? askubuntu.com/questions/457204/… Commented Dec 22, 2016 at 13:53
  • It won't work if screen is locked
    – 0andriy
    Commented Dec 28, 2020 at 17:09
0

To lock the screen via terminal (for Ubuntu 14.04 and 16.04) I use:

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

Therefore to unlock it this would work:

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

Unfortunately I don't have SSH installed to test it. I can test it from the Terminal when the screen is already unlocked and it gives no error message.

I did find another post where this is supposed to work:

dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call --print-reply --reply-timeout=20000 /org/gnome/ScreenSaver org.gnome.ScreenSaver.SetActive boolean:false

The advantage claimed here is that it doesn't ask for a password to unlock the screen. The full thread is here: (Unlock gnome-screensaver instead of deactivating)

1
  • Yes, you are right. But the question is if you unlock screen via Lock button on status bar, then the use the two unlock commands you mentioned won't work. These two unlock commands only works if the lock screen is gnome classical screensaver. But when click Lock button on status bar, it will use the new Unity screensaver. So I update my question: Is there a way to change the original way Lock button clicked, and change it to use gnome classical screensaver.
    – lee
    Commented Dec 22, 2016 at 4:00
0

Not sure how to switch to gnome-classical screensaver, however the gnome-screensaver-command bug workaround definitely works:

First, enable on-screen keyboard:

gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true

The on-screen keyboard appears when you first sign-in but you can close it.
Lock the screen (needs to happen after enabling on-screen keyboard)
Now gnome-screensaver-command -d works to unlock the screen.

Should work with 14.04 from ssh:

export DISPLAY=:0
gnome-screensaver-command -d

For 16.04, need to set dbus session also:

export DISPLAY=:0
export $(cat /proc/`pidof compiz`/environ | tr '\0' '\n' | grep DBUS_SESSION_BUS_ADDRESS )
gnome-screensaver-command -d

Or better yet, just use loginctl which doesn't need any workaround:

loginctl unlock-sessions

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .