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