blob: eb33ff1780aa5d6e1b3b77778ac4787ba72c358a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/usr/bin/perl -w
use strict;
#
# This handy script watches when the screensaver activates and
# toggles the LCD backlight. You won't see more than a
# second of the screensaver, so you might as well chose one
# which consumes few MIPS/battery.
#
# You will probably want to make this script owned by root
# and SUID. Also you will need the perl-suidperl package installed
# for RedHat systems.
# chown root lightwatch
# chmod u+x lightwatch
#
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin';
$<=0; # become root not just effective root
open(XS,"/usr/X11R6/bin/xscreensaver-command -watch|") or die;
while(<XS>) {
if(/^BLANK/i) {
system("radeontool light off");
} elsif(/^UNBLANK/i) {
system("radeontool light on");
}
}
|