Xubuntu suspend by commandline / keyboard shortcut

Step-by-Step descriptions of how to do things.

Xubuntu suspend by commandline / keyboard shortcut

Postby ^rooker » Fri Oct 27, 2017 5:34 pm

This HowTo explains how to be able to suspend a (X)ubuntu machine using a keyboard shortcut.
(That's super convenient. I loooove it! :D )

This method was tested on Xubuntu 12.04 and 16.04, but should work on all GNU/Linux distros that offer a shell-command for suspend.
You need to configure your user to be allowed to execute the supend command "pm-suspend" with superuser-rights, but without prompting for a password.

Therefore you need to configure the "sudo" configuration.
IMPORTANT: Never edit /etc/sudoers directly, but use "visudo":
Code: Select all
$ sudo visudo

Add a line to sudo config so that your user can suspend without requiring to enter a password.
Code: Select all
me ALL= NOPASSWD: /usr/sbin/pm-suspend

In this example the username is "me".

Now assign a keyboard shortcut for your window manager.
In XFCE this is done in "Settings > Keyboard > Application Shortcuts".
Add the following command:
Code: Select all
sudo pm-suspend

... and assign a keyboard shortcut as you like ;)

That's it!
You can now send your PC to sleep using a keyboard shortcut. 8)
  • 0

Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
User avatar
Site Admin
Posts: 1444
Joined: Fri Aug 29, 2003 8:39 pm
Reputation: 0

Return to HowTo's

Who is online

Users browsing this forum: No registered users and 2 guests

Who is online over last 24 hours

Users browsed this forum in the last 24 hours: No registered users and 17 guests

Reputation System ©'