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~~

lee
  • 41

3 Answers3

1

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

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
lemonsqueeze
  • 1,664
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