40 lines
779 B
Perl
Executable File
40 lines
779 B
Perl
Executable File
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
my $maxfile = "/sys/class/leds/tpacpi\:\:kbd_backlight/max_brightness";
|
|
my $current = "/sys/class/leds/tpacpi\:\:kbd_backlight/brightness";
|
|
|
|
my ($max, $now, $new);
|
|
if (open(my $m, '<', $maxfile)) {
|
|
$max = readline($m);
|
|
chomp $max;
|
|
close($m);
|
|
} else {
|
|
print "Failed to read $maxfile\n";
|
|
exit;
|
|
}
|
|
print STDERR "max = $max\n";
|
|
|
|
if (open(my $c, '<', $current)) {
|
|
$now = readline($c);
|
|
chomp $now;
|
|
close($c);
|
|
} else {
|
|
print "Failed to read $current\n";
|
|
exit;
|
|
}
|
|
print STDERR "now = $now\n";
|
|
|
|
if (open(my $fh, '>', $current)) {
|
|
$new = (($now+1) % ($max+1));
|
|
chomp $new;
|
|
print $fh $new;
|
|
close($fh);
|
|
} else {
|
|
print "Failed to write $current\n";
|
|
exit;
|
|
}
|
|
print STDERR "new = $new\n";
|