Topic: Screen Off Hack
Hi There,
I wrote a hack in perl to toggle the screen on/off if the upper corner is clicked. It seems to work even if widgets are running. Through trial and error I found that the upper corner is at > 3500, 3500
You should be able to run the code using debugchumby or using the rcS hack.
Here is he code:
#! /usr/bin/perl
# sleep for 2 minutes to allow chumby control panel boot-up
# this tries to guarantee that the current dim level has been written to "dimlevel"
sleep(2*60);
# get the current dimlevel
$dim_level = `cat /proc/sys/sense1/dimlevel`;
chop($dim_level);
# initialize toggle
$toggle = 2;
$x = 0; # default coord
$y = 0; # default coord
# wait for a good click event (one with x and y coordinates NOT 0)
while( ($x <= 0) ||
($y <= 0) ) {
$click = 0; # no click yet
$event = ""; # no event yet
# look for a click event
$event = `head -1 /proc/chumby/touchscreen/coordinates | grep pen-down`;
if( $event =~ /x=(\d+)\s+y=(\d+).*(pen-down)/) {
$click = 1;
$x = $1;
$y = $2;
} else {
$x = 0;
$y = 0;
}
# wait for no click event
if( $click == 1 ) {
$event = "";
while( $event == "") {
$event = `head -1 /proc/chumby/touchscreen/coordinates | grep pen-up`;
}
$click = 0; # click even is done
}
# upper-left ?
if( ($x > 3600) &&
($y > 3600) ) { # toggle
if($toggle == 2) { # off
system("echo 2 > /proc/sys/sense1/dimlevel");
$toggle = 0;
} else { # turn on at dimlevel
# full on then dim; must do it this way
system("echo 0 > /proc/sys/sense1/dimlevel");
system("echo $dim_level > /proc/sys/sense1/dimlevel");
# set up for next toggle
$toggle = 2;
}
}
$x = 0;
$y = 0;
}
Regards,
Jose