Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to get my screen to turn off whenever I lock my screen. I know that in Power Management, there's an option to turn off the screen after a set amount of time, and I know about xset dpms force off, but the former doesn't allow me to turn off the screen from the logout menu, and the latter only turns the screen off for a short amount of time (1 minute or so. The screen just turns back on by itself).

Is there a script I can modify to change what happens when "Lock screen" from the logout menu is selected, or is there a script I can add to the panel to lock the screen and then turn the monitor off (and turning it back on when I shake the mouse or something)?

Thanks.

share|improve this question
    
In Ubuntu prior to 9.10, I had a script that did gnome-screensaver-command --lock; xset dpms force off and that actually worked. But it doesn't anymore (same as you, monitor comes back on after 30 sec). –  Brian Oct 14 '10 at 13:34

2 Answers 2

up vote 1 down vote accepted
#!/usr/bin/env perl
system 'sleep 1';
system 'xset dpms force off';
system 'gnome-screensaver-command -i &';
while(<>){`killall gnome-screensaver-command`;exit}
share|improve this answer

You could use vbetool (which requires lrmi)

vbetool dpms off

You could plug it into this following perl script (copied from gnomescreensaver.org and slighly modified for the event)

my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'\"";

open (IN, "$cmd |");

while (<IN>) {
  if (m/^\s+boolean true/) {

       print "*** Session is idle ***\n";

  } elsif (m/^\s+boolean false/) {

       print "*** Session is no longer idle ***\n";

  }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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