Ubuntu – Automatically locking screen without shutting it off


Hey everyone— I have a home theater PC running Ubuntu 11.10, outputting over HDMI (for audio and video). I'm having an issue: I'd like the screen to lock automatically (when video is not playing, of course) but do not want the screen to turn off automatically, because that kills audio. I can manually lock the screen, of course, but it appears that if you set the "Turn off screen" setting to "never", the screen will never lock, no matter what the "lock screen" timeout is set to.

Is there a way to do what I'm asking, or will I have to install xscreensaver?

Best Answer

xscreensaver would be simpler

It would be nice for HDMI audio to stay active, wouldn't it... I don't think there is a way to disable screensaver while video is playing with ubuntu settings. Some players have this setting built in.

I've been playing around with

xset dpms force standby

It does not work with ATI cards but what does :(

You can check more settings with xset -h

Try this, it should work. I wish there was a better solution. It's a blank screensaver. Does not turn off monitor.

xset s blank
xset s 300
xset s on

This blanks the screen after 300sec.

To instantly activate use

sh -c "sleep 1; xset s activate"

if you need to lock the screen, you can use

gnome-screensaver-command -l

You can create a desktop launcher that can be dragged to the unity launcher with

gnome-desktop-item-edit --create-new

If you don't want to use it anymore> To deactivate

xset s off


xset s default

should work.

see here for more details.

So many people use hdmi audio. There should be a better solution.