From 72eb38c69d59ff29aa1662f4576ddf1fa3b35b9e Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Mon, 5 Jul 2021 15:06:20 +0200 Subject: Update scrot commands --- .local/bin/get-focussed-monitor | 43 +++++++++++++++++++++++++++++++++++++++++ .local/bin/mscrot | 6 ++++++ .local/bin/sscrot | 8 ++++++++ .local/bin/wscrot | 6 ++++++ 4 files changed, 63 insertions(+) create mode 100755 .local/bin/get-focussed-monitor create mode 100755 .local/bin/mscrot create mode 100755 .local/bin/sscrot create mode 100755 .local/bin/wscrot diff --git a/.local/bin/get-focussed-monitor b/.local/bin/get-focussed-monitor new file mode 100755 index 0000000..4d7bbd4 --- /dev/null +++ b/.local/bin/get-focussed-monitor @@ -0,0 +1,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:' $ = [ \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; + } +} diff --git a/.local/bin/mscrot b/.local/bin/mscrot new file mode 100755 index 0000000..3848aaa --- /dev/null +++ b/.local/bin/mscrot @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +p="~/pictures/scrot" +cmd="mv \$f ${p} && notify-send \"Screenshot\" \"Saved to ${p}/\$f\"" + +scrot -mz multi-%Y%m%d%H%M%S.png -e "${cmd}" diff --git a/.local/bin/sscrot b/.local/bin/sscrot new file mode 100755 index 0000000..2d4c049 --- /dev/null +++ b/.local/bin/sscrot @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +p="~/pictures/scrot" +cmd="mv \$f ${p} && notify-send \"Screenshot\" \"Saved to ${p}/\$f\"" + +eval "$(get-focussed-monitor --coords)" + +scrot -a $X,$Y,$W,$H -z screen-%Y%m%d%H%M%S.png -e "${cmd}" diff --git a/.local/bin/wscrot b/.local/bin/wscrot new file mode 100755 index 0000000..2970713 --- /dev/null +++ b/.local/bin/wscrot @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +p="~/pictures/scrot" +cmd="mv \$f ${p} && notify-send \"Screenshot\" \"Saved to ${p}/\$f\"" + +scrot -bsz window-%Y%m%d%H%M%S.png -e "${cmd}" -- cgit v1.1