Ubuntu – How to reduce delay before locking after pressing lock button

17.04lock-screen

On my freshly installed Ubuntu 17.04 lock screen appears about 5-10 seconds after I press Win+L or "lock" button in the upper right corner. During these 5-10 seconds nothing is happening. As if I didn't press the button.

How do I reduce this lag? I want it to lock immediately.

"Lock screen after" is set to "screen turns off":

screenshot of Brightness & Lock settings

Update 10.05.2017

journalctl -f shows me these messages:

май 10 13:16:26 marko-ubuntu compiz[6140]: WARN  2017-05-10 13:16:26 unity.glib.dbus.proxy GLibDBusProxy.cpp:487 Calling method "EmitEvent" on object path: "/com/ubuntu/Upstart" failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name com.canonical.Unity.Test.Upstart was not provided by any .service files
май 10 13:16:26 marko-ubuntu systemd[5720]: Starting Backing Service for the Unity Panel in Lockscreen mode...
май 10 13:16:26 marko-ubuntu systemd[5720]: Started Backing Service for the Unity Panel in Lockscreen mode.
май 10 13:16:26 marko-ubuntu systemd[5720]: Reached target A target that, when running, represents the screen being locked.
май 10 13:16:40 marko-ubuntu compiz[6140]: gkr-pam: unlocked login keyring
май 10 13:16:40 marko-ubuntu repowerd[1051]: LogindSystemPowerControl: change_manager_properties(), BlockInhibited=shutdown:sleep:handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch
май 10 13:16:40 marko-ubuntu unity-panel-ser[6150]: menus_destroyed: assertion 'IS_WINDOW_MENU(wm)' failed
май 10 13:16:40 marko-ubuntu unity-panel-ser[6150]: menus_destroyed: assertion 'IS_WINDOW_MENU(wm)' failed
май 10 13:16:40 marko-ubuntu systemd[5720]: Stopped target A target that, when running, represents the screen being locked.
май 10 13:16:40 marko-ubuntu systemd[5720]: Stopping Backing Service for the Unity Panel in Lockscreen mode...
май 10 13:16:40 marko-ubuntu compiz[6140]: WARN  2017-05-10 13:16:40 unity.glib.dbus.proxy GLibDBusProxy.cpp:487 Calling method "EmitEvent" on object path: "/com/ubuntu/Upstart" failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name com.canonical.Unity.Test.Upstart was not provided by any .service files
май 10 13:16:41 marko-ubuntu unity-panel-ser[9016]: Source ID 4294967295 was not found when attempting to remove it
май 10 13:16:41 marko-ubuntu systemd[5720]: Stopped Backing Service for the Unity Panel in Lockscreen mode.

I've pressed "Lock" button at second 20. Screen transitioned into locked mode at second 26. So there was a 6 second lag. At second 40 I've logged back in.

Update 18.05.2017

It happens with two monitors only. It does not happen with one monitor.

Best Answer

I searched a lot to find anything (configuration) that may be related to this lag but to luck. It seems that there was a known bug [old]. anyway we still can use other tools to achieve what we want unless that bug is effecting you which you can use the above link instruction to get rid of it..

First use these commands to lock your screen, see which one of them is work better for you and which one you prefer to use.

$ dm-tool lock
$ gnome-screensaver-command -a  # starts screen saver

Now open system settings go to keyboard section and shortcuts tabs.

Now you can select custom shortcuts and asign something Ctrl+Alt+l to a command like dm-tool lock; Cause by default we can't use Super+l.

However if you insist to use Super+l to run your preferred command, set it as your key-binding and follow along to make it work.

enter image description here

To disable unity's Super+l key-binding, run:

dconf write /org/compiz/profiles/unity/plugins/unityshell/lock-screen "''"

To restore default behavior:

dconf reset /org/compiz/profiles/unity/plugins/unityshell/lock-screen

or install compiz setting manager:

$ sudo apt install compizconfig-settings-manager

then run it:

$ ccsm

Go to ubuntu unity plugin section. on line two, Key to lock the screen, click on the button <Super>l, uncheck the Enabled check-box click on ok.

enter image description here

Related Question