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:

sh -c "dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock && dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend"
  • Fabulous and perfectly bindable. I'd been struggling with pm-suspend and gnome-screensaver-command, but this works much better. – James Tomasino Apr 25 '15 at 16:10
  • Unfortunately, the suspend signal doesn't work for me. I get Error org.freedesktop.DBus.Error.UnknownMethod: Method "Suspend" with signature "" on interface "org.freedesktop.UPower" doesn't exist in the terminal. – Dustin Oprea Feb 7 '18 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.