line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Flower::Chronos::X11; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
23298
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
47
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1666
|
use Encode; |
|
2
|
|
|
|
|
24854
|
|
|
2
|
|
|
|
|
974
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
3
|
|
|
3
|
0
|
4258
|
my $class = shift; |
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
|
|
8
|
my $self = {}; |
12
|
3
|
|
|
|
|
8
|
bless $self, $class; |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
|
|
9
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub get_active_window { |
18
|
3
|
|
|
3
|
0
|
583
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
16
|
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
|
|
|
|
|
6
|
my ($id) = @_; |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
10
|
my $dump = $self->_run_xprop('-id', $id); |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
122
|
my $info = {}; |
35
|
3
|
|
|
|
|
9
|
$info->{id} = $id; |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
18
|
($info->{class}) = $dump =~ m/WM_CLASS\(STRING\) = (.*)/m; |
38
|
3
|
|
|
|
|
19
|
($info->{name}) = $dump =~ m/WM_NAME\(.*?\) = (.*)/m; |
39
|
3
|
|
|
|
|
14
|
($info->{role}) = $dump =~ m/WM_WINDOW_ROLE\(STRING\) = (.*)/m; |
40
|
3
|
|
|
|
|
9
|
($info->{command}) = $dump =~ m/WM_COMMAND\(.*?\) = (.*)/m; |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
12
|
$info->{name} = decode('UTF-8', $info->{name}); |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
100
|
|
|
303
|
$info->{$_} //= '' for keys %$info; |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
9
|
return $info; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _get_active_window_id { |
50
|
3
|
|
|
3
|
|
5
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
3
|
|
|
|
|
10
|
my $active_window = $self->_run_xprop('-root', '_NET_ACTIVE_WINDOW'); |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
163
|
my ($id) = $active_window =~ m/\# ([^\s]+)/; |
55
|
3
|
|
|
|
|
12
|
$id =~ s{,$}{}; |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
8
|
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; |