Whitespace
This commit is contained in:
parent
9c5b60d42f
commit
675ba63687
104
thinkpad/blc.pl
104
thinkpad/blc.pl
|
@ -106,7 +106,7 @@ sub get_min
|
||||||
sub writable
|
sub writable
|
||||||
{
|
{
|
||||||
if (! -w $cur_file) {
|
if (! -w $cur_file) {
|
||||||
die "You don't have permission to write $cur_file\n";
|
die "You don't have permission to write $cur_file\n";
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ my (@output, $target, $silent, $notify);
|
||||||
|
|
||||||
my $operation_found = 0;
|
my $operation_found = 0;
|
||||||
if (scalar @ARGV) {
|
if (scalar @ARGV) {
|
||||||
while ($arg = shift) {
|
while ($arg = shift) {
|
||||||
if ($arg eq '%') {
|
if ($arg eq '%') {
|
||||||
push @output,int(get_current()/get_max()*100);
|
push @output,int(get_current()/get_max()*100);
|
||||||
} elsif ($arg eq '^') {
|
} elsif ($arg eq '^') {
|
||||||
|
@ -266,52 +266,52 @@ if (scalar @ARGV) {
|
||||||
} else {
|
} else {
|
||||||
$duration = 1000;
|
$duration = 1000;
|
||||||
}
|
}
|
||||||
} elsif ($arg eq '+') {
|
} elsif ($arg eq '+') {
|
||||||
unshift(@ARGV,1);
|
unshift(@ARGV,1);
|
||||||
unshift(@ARGV,'+=');
|
unshift(@ARGV,'+=');
|
||||||
} elsif ($arg =~ /^\+=/) {
|
} elsif ($arg =~ /^\+=/) {
|
||||||
my $offset;
|
my $offset;
|
||||||
if ($arg =~ m/^\+=(.+)$/) {
|
if ($arg =~ m/^\+=(.+)$/) {
|
||||||
$offset = $1;
|
$offset = $1;
|
||||||
} else {
|
} else {
|
||||||
$offset = shift || die "+= without accompanying offset value\n";
|
$offset = shift || die "+= without accompanying offset value\n";
|
||||||
}
|
}
|
||||||
unless ($offset =~ /^\d+$/) {
|
unless ($offset =~ /^\d+$/) {
|
||||||
die "+= <value> is not a number ($offset)\n";
|
die "+= <value> is not a number ($offset)\n";
|
||||||
}
|
}
|
||||||
for (my $j=0;$j<$offset;$j++) {
|
for (my $j=0;$j<$offset;$j++) {
|
||||||
$target = increment();
|
$target = increment();
|
||||||
@output = to_percent($target);
|
@output = to_percent($target);
|
||||||
}
|
}
|
||||||
$operation_found = 1;
|
$operation_found = 1;
|
||||||
} elsif ($arg eq '-') {
|
} elsif ($arg eq '-') {
|
||||||
unshift(@ARGV,1);
|
unshift(@ARGV,1);
|
||||||
unshift(@ARGV,'-=');
|
unshift(@ARGV,'-=');
|
||||||
} elsif ($arg =~ /^-=/) {
|
} elsif ($arg =~ /^-=/) {
|
||||||
my $offset;
|
my $offset;
|
||||||
if ($arg =~ m/^-=(.+)$/) {
|
if ($arg =~ m/^-=(.+)$/) {
|
||||||
$offset = $1;
|
$offset = $1;
|
||||||
} else {
|
} else {
|
||||||
$offset = shift || die "-= without accompanying offset value\n";
|
$offset = shift || die "-= without accompanying offset value\n";
|
||||||
}
|
}
|
||||||
unless ($offset =~ /^\d+$/) {
|
unless ($offset =~ /^\d+$/) {
|
||||||
die "-= <value> is not a number ($offset)\n";
|
die "-= <value> is not a number ($offset)\n";
|
||||||
}
|
}
|
||||||
for (my $j=0;$j<$offset;$j++) {
|
for (my $j=0;$j<$offset;$j++) {
|
||||||
$target = decrement();
|
$target = decrement();
|
||||||
@output = to_percent($target);
|
@output = to_percent($target);
|
||||||
}
|
}
|
||||||
$operation_found = 1;
|
$operation_found = 1;
|
||||||
} elsif ($arg =~ m/^=/) {
|
} elsif ($arg =~ m/^=/) {
|
||||||
my $value;
|
my $value;
|
||||||
if ($arg =~ m/^=(.+)$/) {
|
if ($arg =~ m/^=(.+)$/) {
|
||||||
$target = $1;
|
$target = $1;
|
||||||
} else {
|
} else {
|
||||||
$target = shift || die "= without accompanying absolute value\n";
|
$target = shift || die "= without accompanying absolute value\n";
|
||||||
}
|
}
|
||||||
unless ($target =~ /^\d+$/) {
|
unless ($target =~ /^\d+$/) {
|
||||||
die "= <value> is not a number ($target)\n";
|
die "= <value> is not a number ($target)\n";
|
||||||
}
|
}
|
||||||
if ($target < 1) {
|
if ($target < 1) {
|
||||||
$target = set(get_min());
|
$target = set(get_min());
|
||||||
} elsif ($target > get_max()) {
|
} elsif ($target > get_max()) {
|
||||||
|
@ -326,7 +326,7 @@ if (scalar @ARGV) {
|
||||||
@output = to_percent($target);
|
@output = to_percent($target);
|
||||||
$operation_found = 1;
|
$operation_found = 1;
|
||||||
} else {
|
} else {
|
||||||
push(@output,$arg);
|
push(@output,$arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -336,7 +336,7 @@ if (scalar @ARGV) {
|
||||||
. '","Current":"'
|
. '","Current":"'
|
||||||
. get_current()
|
. get_current()
|
||||||
. '","Percentage","'
|
. '","Percentage","'
|
||||||
. int(get_current()/get_max()*100)
|
. int(get_current()/get_max()*100)
|
||||||
. '%"}}'
|
. '%"}}'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -354,26 +354,26 @@ if ($silent) {
|
||||||
$concat .= $_;
|
$concat .= $_;
|
||||||
}
|
}
|
||||||
=pod
|
=pod
|
||||||
use Gtk2::Notify -init, "Backlight";
|
use Gtk2::Notify -init, "Backlight";
|
||||||
my $notification = Gtk2::Notify::new('Backlight', $concat, '', "notification-display-brightness");
|
my $notification = Gtk2::Notify::new('Backlight', $concat, '', "notification-display-brightness");
|
||||||
|
|
||||||
$notification->set_hint_string('x-canonical-private-synchronous','blc');
|
$notification->set_hint_string('x-canonical-private-synchronous','blc');
|
||||||
$notification->set_urgency('NOTIFY_URGENCY_LOW');
|
$notification->set_urgency('NOTIFY_URGENCY_LOW');
|
||||||
$notification->set_hint_int32('value',(split('%',$concat))[0]);
|
$notification->set_hint_int32('value',(split('%',$concat))[0]);
|
||||||
$notification->set_timeout($duration);
|
$notification->set_timeout($duration);
|
||||||
$notification->show();
|
$notification->show();
|
||||||
exit;
|
exit;
|
||||||
print "notify-send --urgency=normal"
|
print "notify-send --urgency=normal"
|
||||||
. ' --icon="notification-display-brightness"'
|
. ' --icon="notification-display-brightness"'
|
||||||
. ' --hint=string:x-canonical-private-synchronous:blc'
|
. ' --hint=string:x-canonical-private-synchronous:blc'
|
||||||
. ' --expire-time=' . $duration
|
. ' --expire-time=' . $duration
|
||||||
. ' "Backlight"'
|
. ' "Backlight"'
|
||||||
. ' "' . $concat . " '" . join("','", @output) . "'\"";
|
. ' "' . $concat . " '" . join("','", @output) . "'\"";
|
||||||
system "notify-send --urgency=normal"
|
system "notify-send --urgency=normal"
|
||||||
. ' --icon="notification-display-brightness"'
|
. ' --icon="notification-display-brightness"'
|
||||||
. ' --hint=string:x-canonical-private-synchronous:blc'
|
. ' --hint=string:x-canonical-private-synchronous:blc'
|
||||||
. ' --hint=int:value:' . (split('%',$concat))[0]
|
. ' --hint=int:value:' . (split('%',$concat))[0]
|
||||||
. ' --expire-time=' . $duration
|
. ' --expire-time=' . $duration
|
||||||
. ' "' . $concat . "\"";
|
. ' "' . $concat . "\"";
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue