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.


Are you sure your xscreensaver is running? You can check the existance of the proceess 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 runing but the bind does not work then maybe you are not binding the key correctly. Try following a solution similiar 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).

  • xscreensaver does seem to be working. Following the other guide and replacing the Command field with xscreensaver-command -lock didn't work either so I tried the lxsession-logout --suspend ; xscreensaver-command -lock and that didn't seem to work either. So i dug around and lxsession-logout --suspend does absolutely nothing! So I tried lxsession-logout and that did work, bringing up the logout, shutdown, and suspend options. So lxsession-logout --suspend seems to be what's not working. So what do I do now? – Hershey Gamer Dec 16 '17 at 19:13
  • Why doesn't your keybind just run xscreensaver-command -lock? I think that is enough. – Jorge Heleno Dec 17 '17 at 16:41
  • I'm not sure why xscreensaver-command -lock isn't working. Is there any way to check why it's not working? – Hershey Gamer Dec 18 '17 at 0:19
  • Try xscreensaver-demo. Use the lock demo on the graphical interface and check if you can lock it. You can also check the logs or just run xscreensaver without daemonizing it using only xscreensaver and when you try to lock check if it spits any error. You can also turn on verbose with the flag -verbose. – Jorge Heleno Dec 18 '17 at 1:05
  • 1
    Ok, so after running xscreensaver-demo it told me I had to daemonize it before I could use it. After I did that xscreensaver-command -lock started working! Thanks so much! :D – Hershey Gamer Dec 19 '17 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.