#!/usr/bin/perl
system("mknod /dev/sonypi c 10 250");
$dev = "/dev/sonypi";
open (F, $dev);
$brightness = `spicctrl -B`; $step = 51; $lightOn = 1; $videoOut = 0; $soundOff = 0;
while (1) { $char = getc F; $num = ord($char);
print "The number is: $num\n";
SWITCH: { if ($num == 12) { &light()}; if ($num == 13) { &mute()}; if ($num == 14) { &volDown()}; if ($num == 15) { &volUp()}; if ($num == 16) { &dim()}; if ($num == 17) { &bright()}; if ($num == 18) { &vgaOut()}; #if ($num == 23) { &system("/sbin/hibernate")}; #if ($num == 24) { &exec("halt")}; #if ($num == 22) { &exec("reboot")}; } } close F;
sub light { if ($lightOn == 1) { system("radeontool light off"); system("echo off > /var/backlight"); $lightOn = 0; } else { system("radeontool light on"); system("echo on > /var/backlight"); $lightOn = 1; } }
sub mute { if ($soundOff == 0) { system("amixer set PCM mute"); system("amixer set Master mute"); system("amixer set 'Master Mono' mute"); system("amixer set Headphone mute"); $soundOff = 1; } else { system("amixer set PCM unmute"); system("amixer set Master unmute"); system("amixer set 'Master Mono' unmute"); system("amixer set Headphone unmute");
$soundOff = 0; } }
sub volDown { # amixer set Master 10%-; system("amixer set Master 10%-"); system("amixer set Headphone 10%-"); }
sub volUp { system("amixer set Master 10%+"); system("amixer set Headphone 10%+"); }
sub checkBright { if($brightness < 0) { $brightness = 0; } if($brightness > 255) { $brightness = 255;} } sub dim { $brightness = $brightness - $step; &checkBright(); system("spicctrl -b $brightness"); }
sub bright { &checkBright(); $brightness = $brightness + $step; system("spicctrl -b $brightness"); }
sub vgaOut { if($videoOut == 0) { system("radeontool dac on"); $videoOut = 1; } else { system("radeontool dac off"); $videoOut = 0; }
}
|