Skip to main content

Sleep shortcut command lubuntu? [Resolved]

I'm trying to set the Sleep Button to actually put the computer to sleep and toggle my screensaver but to make this happen I have to have a terminal command to bind to the sleep button. So by going to Preferences -> Setup Hot Keys -> Programs and then assing a command to the sleep key.

I tried using the command xscreensaver-command -lock ; lxsession-logout --suspend but when I press the sleep button nothing happens. What am I doing wrong? My Lubuntu version is 17.10.

Question Credit: Hershey Gamer
Question Reference
Asked September 21, 2019
Posted Under: Unix Linux
1 Answers

Are you sure your xscreensaver is running? You can check the existence of the process with ps -aux | grep -v ps | grep xscreensaver. If xscreensaver is not running, you should run xscreensaver --no-splash & disown and you would want to put this command in your .xinitrc or whatever lightdm uses for on login configurations.

If you already have xscreensaver running but the bind does not work, then maybe you are not binding the key correctly. Try following a solution similar to the one in this other question and replace the Command field with xscreensaver-command -lock.

It is also possible that lxsession-logout is doing something weird to xscreensaver (I don't know, never used lxsession-logout with xscreensaver), but nonetheless you should execute lxsession-logout --suspend before the xscreensaver-command -lock since lxsession-logout prompts for a logout screen and xscreensaver-command -lock locks your screen immediately (depending on the fade duration).

credit: Pang
Answered September 21, 2019
Your Answer