Ubuntu – How to create keyboard shortcut which initiates suspend

function keysgnomekeyboardshortcut-keyssuspend

When I was running the Unity shell I was able to do Fn + F1 and get my machine to suspend, however now that I am running Gnome Shell, when I do this keyboard shortcut, absolutely nothing happens, so I was wondering if there was anyway to get it so that when doing that keyboard shortcut, my machine does actually suspend?

I have tried looking in my System Settings and found nothing obvious, I have also looked in Gnome Tweak Tool, but still nothing obvious. When I had Unity it was just the case though, and even when I had Windows 7 before that it was the case that that keyboard combination did that, I have never needed to configure anything specially, nor have I to get this working.

OS Information:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 15.04
Release:    15.04
Codename:   vivid

Best Answer

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:


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.

Related Question