Take ownership of brightness file, if possible
Improve errors, if not.
This commit is contained in:
parent
62e9b4b53d
commit
7630ee5878
|
@ -65,6 +65,7 @@
|
||||||
|
|
||||||
# Files containing current and max brightness values
|
# Files containing current and max brightness values
|
||||||
my $cur_file = "/sys/class/backlight/intel_backlight/brightness";
|
my $cur_file = "/sys/class/backlight/intel_backlight/brightness";
|
||||||
|
chmod('0644',$cur_file) unless ( -w $cur_file );
|
||||||
my $max_file = "/sys/class/backlight/intel_backlight/max_brightness";
|
my $max_file = "/sys/class/backlight/intel_backlight/max_brightness";
|
||||||
my $cur_log = $ENV{HOME}."/.spool/blc.current";
|
my $cur_log = $ENV{HOME}."/.spool/blc.current";
|
||||||
my $last_log = $ENV{HOME}."/.spool/blc.last";
|
my $last_log = $ENV{HOME}."/.spool/blc.last";
|
||||||
|
@ -125,9 +126,12 @@ sub logger
|
||||||
sub writef
|
sub writef
|
||||||
{
|
{
|
||||||
my $target = shift;
|
my $target = shift;
|
||||||
open(my $fh,'>',$cur_file);
|
if (open(my $fh,'>',$cur_file)) {
|
||||||
print $fh $target;
|
print $fh $target;
|
||||||
close($fh);
|
close($fh);
|
||||||
|
} else {
|
||||||
|
print "Failed to write to $cur_file: $!\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub increment
|
sub increment
|
||||||
|
|
Loading…
Reference in New Issue