How can I suspend my computer from the command line and, once it wakes up, display Unity's lock screen? I want to replicate exactly what happens when I click on the system cog icon at the top right of the Unity panel and go to Suspend
in Ubuntu 14.04 (not an earlier version!).
I've found many answers that do not work, such as those found here and here. All of them are for older versions of Ubuntu or invoke either gnome-screensaver or xscreensaver's lock screen.
This command, for instance, suspends the computer, but does not lock the screen:
dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend
, despite Require my password when waking from suspend
being checked in the Brightness & Lock system
settings.
Actually, I don't even know how to invoke Unity's lock screen at all in 14.04: the closest I can come to is dm-tools lock
, but this is not quite the same, as it allows you to sign in as a different user and shows more indicators.
Since I figured out how to get the 14.04 lock screen, I just chained the dbus lock command with the suspend one: