#!/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:' $ = [ \d+ ] \s* 'y:' $ = [ \d+ ] /; for @xrandr -> $monitor { my $match = $monitor ~~ m/ $ = [ \d+ ] 'x' $ = [ \d+ ] '+' $ = [ \d+ ] '+' $ = [ \d+ ] /; next unless $match ≤ $mouse ≤ ($match + $match); next unless $match ≤ $mouse ≤ ($match + $match); say qq[MONITOR="{$monitor.words.first}"]; if ($coords) { say qq[W="{$match}"]; say qq[H="{$match}"]; say qq[X="{$match}"]; say qq[Y="{$match}"]; } last; } }