xbacklight: fix incorrect path, add comment
This commit is contained in:
23
xbacklight
23
xbacklight
@@ -1,4 +1,10 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# TODO: check intel' backlight path too if generic is not found
|
||||||
|
# this script should have suid bit set and must have root owner :(
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings "all";
|
||||||
|
|
||||||
my $arg = $ARGV[0];
|
my $arg = $ARGV[0];
|
||||||
my $step = 10; # measured in percents
|
my $step = 10; # measured in percents
|
||||||
@@ -6,12 +12,15 @@ my $step = 10; # measured in percents
|
|||||||
sub fsread($); # read 1-st line from file
|
sub fsread($); # read 1-st line from file
|
||||||
sub fswrite(@); # write string to file
|
sub fswrite(@); # write string to file
|
||||||
|
|
||||||
my $brightnessfile = "/sys/class/backlight/acpi_video0/brightness";
|
#my $prefix = "/sys/class/backlight/acpi_video0";
|
||||||
my $maxbrightness = fsread("/sys/class/backlight/acpi_video0/max_brightness");
|
my $prefix = "/sys/class/backlight/intel_backlight";
|
||||||
my $currbrightness = fsread($brightnessfile);
|
|
||||||
|
|
||||||
my $a = $maxbrightness / 100;
|
my $brightnessfile = "$prefix/brightness";
|
||||||
$step = int($step * $a);
|
my $maxbrightness = fsread("$prefix/max_brightness");
|
||||||
|
my $currbrightness = fsread("$prefix/brightness");
|
||||||
|
|
||||||
|
my $p = $maxbrightness / 100;
|
||||||
|
$step = int($step * $p);
|
||||||
|
|
||||||
if ( $arg eq "up" ) {
|
if ( $arg eq "up" ) {
|
||||||
if ($currbrightness != $maxbrightness) {
|
if ($currbrightness != $maxbrightness) {
|
||||||
@@ -38,7 +47,7 @@ if ( $arg eq "up" ) {
|
|||||||
|
|
||||||
sub fsread($) {
|
sub fsread($) {
|
||||||
my $fname = shift;
|
my $fname = shift;
|
||||||
open (F, $fname) || die;
|
open (F, $fname) || die "Unable to read $fname: $!\n";
|
||||||
my $str = <F>;
|
my $str = <F>;
|
||||||
close F;
|
close F;
|
||||||
return $str;
|
return $str;
|
||||||
@@ -47,7 +56,7 @@ sub fsread($) {
|
|||||||
sub fswrite (@) {
|
sub fswrite (@) {
|
||||||
my $str = shift;
|
my $str = shift;
|
||||||
my $fname = shift;
|
my $fname = shift;
|
||||||
open(OF, ">", $fname) || die;
|
open(OF, ">", $fname) || die "Unable to write $fname: $!\n";
|
||||||
print OF $str;
|
print OF $str;
|
||||||
close OF;
|
close OF;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user