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
|
|
956
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
22
|
1
|
|
|
1
|
|
17
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
23
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
5
|
use Getopt::EX::autocolor qw(rgb_to_brightness); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
26
|
1
|
|
|
1
|
|
497
|
use App::cdif::Command::OSAscript; |
|
1
|
|
|
|
|
19653
|
|
|
1
|
|
|
|
|
40
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
29
|
1
|
|
|
1
|
|
8
|
no warnings 'once'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
30
|
1
|
|
|
1
|
|
581
|
use Getopt::EX::Colormap; |
|
1
|
|
|
|
|
15836
|
|
|
1
|
|
|
|
|
235
|
|
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__ |