How to create keyboard shortcut which initiates suspend

I tested the command mentioned here on Gnome 15.04, and it did the job well. The next thing to do is then to make it available under a shortcut key.

The easiest way would be to create a small script of it:

#!/bin/bash

dbus-send --system --print-reply \
  --dest="org.freedesktop.login1" \
  /org/freedesktop/login1 \
  org.freedesktop.login1.Manager.Suspend boolean:true

save it as initiate_suspend.sh, and make it available under a shortcut key. To do that works the same in Gnome as it works in Unity: choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:

/bin/bash /path/to/initiate_suspend.sh

to a shortcut key combination of your choice.


To suspend Ubuntu 18.10 I use the Super key to launch a command and type sus to highlight the Suspend command, then hit RETURN.

Not quick as elegant as SUPER-l to lock screen, but it works without adding any configuration and no need for a mouse.

Thank you.