How to create keyboard shortcut which initiates suspend
Solution 1
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.
Solution 2
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.
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
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
-
Mitch almost 9 yearsComments are not for extended discussion; this conversation has been moved to chat.
-
Jacob Vlijm almost 9 years@Mitch sorry (again) I'll remember for next time.
-
Mitch almost 9 yearsNo worries.. -:)
-
jarno about 3 yearsSeems to work in Xfce, too, though it does not lock desktop. (Xfce has a specific command
xfce4-session-logout --suspend
which does, if set)