After upgrading ubuntu 18.04 to 18.10 I noticed, that closing lid of laptop doesn't lock screen. And after opening it back it's enough to just use touchpad to unlock screen, no password is required.
This seams to be not acceptable by security reasons. The alternative I found is to change HandleLidSwitch in/etc/systemd/logind.conf to lock, but then it stop suspending, which seams to be not acceptable to, because of battery using.
Another solution found in archwiki, and is adding a systemd unit like
[Unit] Description=User suspend actions Requires=dbus.socket Before=sleep.target [Service] User=pavel Type=forking Environment=DISPLAY=:0 Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus ExecStartPre= ExecStart=bash -c "env && /usr/bin/gnome-screensaver-command -l" ExecStartPost=/bin/sleep 1 [Install] WantedBy=sleep.target
This works most time, but sometimes silently fails with notification "lock was blocked by an application" after opening laptop, and
gnome-screensav: unable to send message: Timeout was reached gnome-screensav: Did not receive a reply from the screensaver.
in log of systemd unit.
Any ideas on ways how to debug this? Or any much easier solutions I failed to found?