blob: 4d7bbd4c6c5df22ef452ce7666b82bc850641801 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/usr/bin/env raku
use v6.d;
sub MAIN (
#Bool:D :$shell = False,
Bool:D :$coords = False,
) {
my @xrandr = shell('xrandr | grep -w connected', :out).out.slurp.lines;
my %monitors;
my $mouse = shell('xdotool getmouselocation', :out).out.slurp.trim ~~ m/
'x:' $<x> = [ \d+ ]
\s*
'y:' $<y> = [ \d+ ]
/;
for @xrandr -> $monitor {
my $match = $monitor ~~ m/
$<width> = [ \d+ ]
'x'
$<height> = [ \d+ ]
'+'
$<x> = [ \d+ ]
'+'
$<y> = [ \d+ ]
/;
next unless $match<x> ≤ $mouse<x> ≤ ($match<x> + $match<width>);
next unless $match<y> ≤ $mouse<y> ≤ ($match<y> + $match<height>);
say qq[MONITOR="{$monitor.words.first}"];
if ($coords) {
say qq[W="{$match<width>}"];
say qq[H="{$match<height>}"];
say qq[X="{$match<x>}"];
say qq[Y="{$match<y>}"];
}
last;
}
}
|