Talk:HOWTO Automatically turn off your monitor

From Gentoo Linux Wiki

Jump to: navigation, search

It should probably be noted that for desktop/CRT users (or in general people that just want screen blanking), you don't need ACPI. If you want your monitor to blank and nothing else, put the DPMS option and the "SuspendTime" in your xorg.conf
On that note, desktop/crt users can't `dpms force off` or `dpms force suspend` either (unless I just screwed something up?), but suspending blanks the monitor and waits for user reactivation. 68.110.115.17 20:35, 25 November 2005 (GMT)

I'm pretty sure 'dpms force off' and 'dpms force suspend' work for my desktop CRTs. There seems to be a bug in the page, the code isn't showing up in the boxes, anyone have a fix for this? -DF

Notice this only works for X sessions. If you switched to a text based virtual terminal session, the screen will just blank but won't power down.

add this line to your /etc/conf.d/local.start setterm -powersave on && setterm -blank 5

--Jhendrix 15:10, 31 August 2006 (UTC)

[edit] nvidia driver problem

I just found out that for the nvidia driver you have to put this option:

Option "DPMS" "TRUE"

in your Section "Device" section or else your monitor won't shut off.192.168.1.20 08:57, 9 July 2006 (UTC)

[edit] perl script to turn off monitor when lid closed

Here is a perl script that can be run as the logged in user which will detect a lid status change and turn on/off the screen as appropriate. This gets past all the problems of having acpid do it - whoever has control of the display controls the blanking of the display. It can be run through .xsession/.xprofile or auto started by your favourite DM/WM. It uses the Linux::Inotify2 module which will need to be installed, either through cpan/g-cpan/manual source compile. It's dirty, dirty perl but it works.

#!/usr/bin/env perl

use strict;
use warnings;
use Linux::Inotify2;
use IO::File;

my $LIDSTATE = "/proc/acpi/button/lid/LID/state";

# create a new object
my $inotify = new Linux::Inotify2
  or die "Unable to create new inotify object: $!" ;

# create watch
$inotify->watch ($LIDSTATE, IN_ACCESS)
  or die "watch creation failed" ;

while() 
  {
    last if $inotify->read;
  }

# read value from acpi proc interface
my $fh = new IO::File $LIDSTATE, "r";
die "$0: Could not open $LIDSTATE: $!\n" if ! $fh;
my ($parname,$parvalue) = split /:/, <$fh>;
$parvalue =~ s/\s+//; chomp $parvalue;
undef $fh;

# act on its state
if($parvalue eq "open")
  {
    qx(/usr/bin/xset dpms force on);
  }
else
  {
    qx(/usr/bin/xset dpms force off);
  }

exec $0;

This hasn't been tested extensively...

--Ymir 23:51, 9 August 2007 (UTC)

Personal tools