Xubuntu suspend by commandline / keyboard shortcut
Posted: 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! )
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":
Add a line to sudo config so that your user can suspend without requiring to enter a password.
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:
... and assign a keyboard shortcut as you like
That's it!
You can now send your PC to sleep using a keyboard shortcut.
(That's super convenient. I loooove it! )
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
Code: Select all
me ALL= NOPASSWD: /usr/sbin/pm-suspend
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
That's it!
You can now send your PC to sleep using a keyboard shortcut.