line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Getopt::EX::autocolor::iTerm |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
command -Mautocolor::iTerm |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This is a L module for iTerm. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SEE ALSO |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
L |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Getopt::EX::autocolor::iTerm; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
912
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
22
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
23
|
1
|
|
|
1
|
|
14
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
6
|
use Getopt::EX::autocolor qw(rgb_to_brightness); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
26
|
1
|
|
|
1
|
|
487
|
use App::cdif::Command::OSAscript; |
|
1
|
|
|
|
|
19566
|
|
|
1
|
|
|
|
|
35
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
29
|
1
|
|
|
1
|
|
7
|
no warnings 'once'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
30
|
1
|
|
|
1
|
|
572
|
use Getopt::EX::Colormap; |
|
1
|
|
|
|
|
15442
|
|
|
1
|
|
|
|
|
215
|
|
31
|
|
|
|
|
|
|
$Getopt::EX::Colormap::RGB24 = 1; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our $debug; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $script_iTerm = <
|
37
|
|
|
|
|
|
|
tell application "iTerm" |
38
|
|
|
|
|
|
|
tell current session of current window |
39
|
|
|
|
|
|
|
background color |
40
|
|
|
|
|
|
|
end tell |
41
|
|
|
|
|
|
|
end tell |
42
|
|
|
|
|
|
|
END |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub rgb { |
45
|
0
|
|
|
0
|
0
|
|
my $result = |
46
|
|
|
|
|
|
|
App::cdif::Command::OSAscript->new->exec($script_iTerm); |
47
|
0
|
|
|
|
|
|
my @rgb = $result =~ /(\d+)/g; |
48
|
0
|
0
|
|
|
|
|
warn Dumper $result, \@rgb if $debug; |
49
|
0
|
|
|
|
|
|
@rgb; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub brightness { |
53
|
0
|
|
|
0
|
0
|
|
my(@rgb) = rgb; |
54
|
0
|
0
|
|
|
|
|
return undef unless @rgb == 3; |
55
|
0
|
0
|
|
|
|
|
return undef if grep { not /^\d+$/ } @rgb; |
|
0
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
rgb_to_brightness @rgb; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__DATA__ |