Making Sleeping Ubuntus Lie

Ubuntu stopped letting me force the display off while in X11 with a change to Gnome Screensaver. I used to just run xset dpms force off but that doesn’t work anymore. Here’s a workaround that also works as a “command” on compiz. I have it set to the top left of my screen, so I just move my mouse over there and it turns off the screen.

sleep 1; xset dpms force off; gnome-screensaver-command -i & while xset q | grep -iq "Monitor is Off"; do sleep 10; done; killall gnome-screensaver-command

You can also put this in a script that you can execute from the command line:

#!/bin/bash

sleep 1
xset dpms force off
gnome-screensaver-command -i &
while xset q | grep -iq "Monitor is Off"
do
    sleep 10
done
killall gnome-screensaver-command

It will exit at most 10 seconds after you move your mouse or hit a key. Let it exit or your screensaver will be inactive for the rest of that session. Or until you run the script again and let it exit. Or until you just run killall gnome-screensaver-command.

Leave a Reply

Your email address will not be published. Required fields are marked *