line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Flower::Chronos::X11; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
23223
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
46
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
47
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1710
|
use Encode; |
|
2
|
|
|
|
|
24580
|
|
|
2
|
|
|
|
|
1045
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
3
|
|
|
3
|
0
|
3746
|
my $class = shift; |
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
|
|
5
|
my $self = {}; |
12
|
3
|
|
|
|
|
6
|
bless $self, $class; |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
|
|
7
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub get_active_window { |
18
|
3
|
|
|
3
|
0
|
458
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
15
|
my $id = $self->_get_active_window_id; |
21
|
3
|
|
|
|
|
18
|
my $info = $self->_get_window_info($id); |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
8
|
return $info; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
0
|
0
|
sub idle_time { int(`xprintidle` / 1000) } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _get_window_info { |
29
|
3
|
|
|
3
|
|
5
|
my $self = shift; |
30
|
3
|
|
|
|
|
4
|
my ($id) = @_; |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
52
|
my $dump = $self->_run_xprop('-id', $id); |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
109
|
my $info = {}; |
35
|
3
|
|
|
|
|
7
|
$info->{id} = $id; |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
15
|
($info->{class}) = $dump =~ m/WM_CLASS\(STRING\) = (.*)/m; |
38
|
3
|
|
|
|
|
13
|
($info->{name}) = $dump =~ m/WM_NAME\(.*?\) = (.*)/m; |
39
|
3
|
|
|
|
|
13
|
($info->{role}) = $dump =~ m/WM_WINDOW_ROLE\(STRING\) = (.*)/m; |
40
|
3
|
|
|
|
|
10
|
($info->{command}) = $dump =~ m/WM_COMMAND\(.*?\) = (.*)/m; |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
10
|
$info->{name} = decode('UTF-8', $info->{name}); |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
100
|
|
|
288
|
$info->{$_} //= '' for keys %$info; |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
8
|
return $info; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _get_active_window_id { |
50
|
3
|
|
|
3
|
|
7
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
3
|
|
|
|
|
8
|
my $active_window = $self->_run_xprop('-root', '_NET_ACTIVE_WINDOW'); |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
141
|
my ($id) = $active_window =~ m/\# ([^\s]+)/; |
55
|
3
|
|
|
|
|
9
|
$id =~ s{,$}{}; |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
7
|
return $id; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _run_xprop { |
61
|
0
|
|
|
0
|
|
|
my $self = shift; |
62
|
0
|
|
|
|
|
|
my (@args) = @_; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return `xprop @args`; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |