I'm on Xubuntu 15.04. I'm trying to run command: xss-lock -- xscreensaver-command -lock & so that my screen will lock after being suspended in Xubuntu using xscreensaver. For some reason, without running this command, Xubuntu will only lock the screen after suspension via the suspend button, but not by shutting the laptop lid like it's configured to. In the Arch wiki where I got this command (it applies equally to Ubuntu since they'd be both using systemd, xfce, and X.org in this scenario, I think) it says to run this command from the X session autostart script. I've tried running this command from xinitrc, rc.local, xfce4's xinitrc, and on session autostart. It will ONLY take effect if I run it from inside a terminal after everything else has started. Why is this? How can I get it to run automatically when X.org starts? Thanks to anyone who would help! :D


Go to the menu, type in startup.


Select "Session and Startup"

startup app dialog

Select the "Application Autostart" tab and click the add button.

add dialog

Enter some details and paste in the command from your question.

Click OK, close the remaining dialogs, log out, log back in, and see if it worked.

  • I already did that, I said to in the question! "I've tried running this command from xinitrc, rc.local, xfce4's xinitrc, and on session autostart." Sorry :( – Peter Bucher May 29 '15 at 1:16
  • Have you tried to put it in $HOME/.xprofile ? – Harris May 29 '15 at 1:19
  • Ah, that's what you mean by "X session autostart script" I thought you meant .Xsession. – Stephen May 29 '15 at 1:25
  • Harris, doing that caused my XFCE session to fail to load. I had to go into CLI mode and delete it to get it back to normal. – Peter Bucher May 29 '15 at 1:28
  • When you tried his suggestion, did you end the command with a & sign? – Stephen May 29 '15 at 1:34

Fixed it. I have no idea why this fixed it, but it did. Basically I copied the command into a file named "suspendwhenlidclosed", gave it permission to execute, and moved it into /usr/bin. Then I used XFCE application autostart to run: suspendwhenlidclosed at start up. I have no idea why just copying the command itself in there wouldn't work, but hey, at least it does now this way!

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.